[reportlab-users] platypus para versus flowables
Tim Middleton
x at vex.net
Tue Jan 23 13:32:37 EST 2007
Found a bug in para.py (traceback below). In general I notice that the
various subclasses of Flowable in the para.py module do not maintain the
same default variables in their __init__ that the Flowable.__init__ sets...
seems dangerously inconsistent, even if some of these subclasses don't use
all the of the variables... easiest fix is to have all of these classes
call the __init__ method of their parent... for example, as the first line
in the FastPara.__init__ method:
Flowable.__init__(self)
[Though it'd probably be better in the long run to change the base classes
to new-style python classes by making them children of "object" and then
use super() calls, such as super(FastPara, self).__init__() ...]
which fixes....
Module reportlab.platypus.doctemplate, line 726, in build
Module reportlab.platypus.doctemplate, line 631, in handle_flowable
Module reportlab.platypus.frames, line 157, in _add
Module reportlab.platypus.flowables, line 103, in drawOn
Module reportlab.platypus.flowables, line 88, in _drawOn
Module reportlab.platypus.para, line 1135, in draw
AttributeError: FastPara instance has no attribute 'height'
But then unfortunately led to ....
Module reportlab.platypus.doctemplate, line 726, in build
Module reportlab.platypus.doctemplate, line 631, in handle_flowable
Module reportlab.platypus.frames, line 157, in _add
Module reportlab.platypus.flowables, line 103, in drawOn
Module reportlab.platypus.flowables, line 88, in _drawOn
Module reportlab.platypus.para, line 1154, in draw
TypeError: len() of unsized object
Which i fixed by changing the initialisation of self.lines in
FastPara.__init__ from None to an empty list.
Above is basically a log of my hacking session trying to get this thing to
work. If the above looks reasonable and real patches are wanted... let me
know.
(I notice in Flowable there is a self.encoding set to None. The variable
does not seem to be used anywhere. Was this intended to set input encoding
perhaps? That would be helpful, rather than having to make sure all strings
are unicode before passing them in... when i have lots of Latin-1 sources
all being added to a big "story" list in various different places in
code... or i guess i could write a wrapper for myself).
--
Tim Middleton | Vex.Net | One afternoon, disgusted, bravo, you fall
x at veX.net | VexTech.ca | asleep. --T.Lilburn (MS)
More information about the reportlab-users
mailing list