Le mardi 10 juin 2014 14:29:27 UTC+2, Cédric Krier a écrit :
>
> On 10 Jun 05:07, Vincent Mora wrote:
> > Hi,
> >
> > My reporting class return a pdf document :
> >
> > class MyReport(Report):
> > __name__ = 'mymodule.myreport'
> >
> > @classmethod
> > def execute(cls, ids, data):
> > # code to create myfile.pdf
> > ...
> > pdf_buffer = None
> > with open('myfile.pdf', 'rb') as pdf:
> > pdf_buffer = pdf.read()
> >
> > return ('pdf', pdf_buffer, False, 'myreport' )
>
> return ('pdf', buffer(pdf_buffer), False, 'myreport' )
>
Works fine, thanks a lot.
> >
> > The problem is that json won't encode binary stuff.
> >
> > I'm trying to understand how it's done for images in odt, or odt itself
> > since its a zip file, but it's a bit tedious and I'd be grateful for
> some
> > help.
>
> As str in Python could be string or binary and to prevent Tryton to
> base64 every string. The convention is to use buffer to differenciate
> the binary str.
>
--
> Cédric Krier - B2CK SPRL
> Email/Jabber: [email protected] <javascript:>
> Tel: +32 472 54 46 59
> Website: http://www.b2ck.com/
>