[reportlab-users] Wordaxe 0.3.0, ReportLab 2.2, MultiBuild and splitting error

Harald Armin Massa haraldarminmassa at gmail.com
Tue Nov 18 09:40:39 EST 2008


Hello,

on updating some projekt to RL 2.2; and wordaxe 0.3.0, I ran into some
obscure wrapping / splitting bug.

As it turned out:

the SplitRoutine within NewParagraph get's problems when doc.multibuild is used.

I tracked it down to:

if not hasattr(self, "_lines"):
# This can only happen when split has been called
# without a previous wrap for this Paragraph.
# From looking at doctemplate.py and frames.py,
# I assume this is only the case if the free space
# in the frame is not even enough for getSpaceBefore.
# Thus we can safely return []
#~ print "split without previous wrap"
return []

NewParagraph of Wordaxe relying on self._lines NOT being present when
there was no "wrap" in the actual build pass, to return "I cannot
split"

BUT...

in a multibuild, in the second build pass that self._lines is present
from the first build pass ... , and _unused is an empty list (as some
wraps from the build pass before have used up everything)

So MY fix was in doctemplate multibuild:

#clean up so multi-build does not go wrong - the frame
#packer might have tacked an attribute onto some flowables
for elem in story:
if hasattr(elem, '_postponed'):
del elem._postponed
if hasattr(elem, '_lines'):
del elem._lines

to extend the "cleanup" part to also delete the _lines attribute of a
NewParagraph; together with the _postponed attribut.

So everything works fine ... but I am not sure if this is really the
best approach, and the NewParagraph split/wrap is quite to challenging
to really be sure.

That's why I am posting this fix for others to enjoy and for more
enlightened ones to check:)

Harald

--
GHUM Harald Massa
persuadere et programmare
Harald Armin Massa
Spielberger Straße 49
70435 Stuttgart
0173/9409607
no fx, no carrier pigeon
-
EuroPython 2009 will take place in Birmingham - Stay tuned!


More information about the reportlab-users mailing list