[reportlab-users] Buggy interaction with flowables.py

Robin Becker reportlab-users@reportlab.com
Thu, 01 Apr 2004 11:17:48 +0100


Thanks for the report Aaron

Aaron Darling wrote:
> Hi, I've been using Zope BackTalk in conjunction with ReportLab's PDF
> generation facilities.  Overall the software has been working
> satisfactorily, but I'd like to mention a buggy interaction between
> backtalk and ReportLab that I encountered.
> 
> Whenever I tried to render a PDF document from backtalk pages that
> contain images I would get the following error message (and traceback):

Your analysis is essentially correct, but I have already committed a
different fix addressed to the same problem.

>     def __init__(self, filename, width=None, height=None, kind='direct',
> mask="auto", lazy=1):
>         """If size to draw at not specified, get it from the image."""
>         self.hAlign = 'CENTER'
>         self._mask = mask
>         # if it is a JPEG, will be inlined within the file -
>         # but we still need to know its size now
>         fp = hasattr(filename,'read')
>         if fp:
>             self.filename = `filename`
>         else:
>             self.filename = filename
> 
> Because the cStringIO object passed as filename has a 'read' attribute,
> self.filename gets the value of `filename`, which ends up being the object
> type and address: <StringO object at 0x8d19bd8>
> Later, this value is passed as a filename to the Python Imaging Library's
> Image.open() function, which of course can't open a file by that name.
> 
> I was able to resolve this problem by changing the lines:
>         if fp:
>             self.filename = `filename`
> to:
>         if fp:
>             self.filename = filename
> 
> 
> As I said, I'm new to python, ReportLab, BackTalk, and PIL, and I don't
> know whether what I've come up with is the right solution to the problem.
> Could somebody else comment?  Do these changes break other functionality?
> 
> BTW, I'm using Zope 2.6.1 with Python 2.1.3, BackTalk from CVS, Python
> Imaging Library 1.1.4 and ReportLab 1.19.
> 
> Thanks
> -Aaron
> _______________________________________________
> reportlab-users mailing list
> reportlab-users@reportlab.com
> http://two.pairlist.net/mailman/listinfo/reportlab-users
> 
>