Reportlab / platypus bug?

Les nagylzs at gmail.com
Tue Mar 15 08:11:28 EDT 2022


Dennis Lee Bieber <wlfraed at ix.netcom.com> ezt írta (időpont: 2022. márc.
14., H 20:03):

> On Mon, 14 Mar 2022 19:17:31 +0100, Les <nagylzs at gmail.com> declaimed the
> following:
>
> >Unfortunately, the reportlab-users mailing list is unavailable (I cannot
> >subscribe). There is paid support but since I already have a workaround, I
> >won't pay for this. I think this is a documentation error of the reportlab
> >package. (They do not mention that stories cannot be reused.)
> >
>
>
> https://github.com/eduardocereto/reportlab/blob/master/src/reportlab/platypus/doctemplate.py
> """
> A document is built when a DocumentTemplate is fed a sequence of Flowables.
> The action of the build consumes the flowables in order and places them
> onto frames on pages as space allows.  When a frame runs out of space the
> next frame of the page is used.  If no frame remains a new page is created.
> A new page can also be created if a page break is forced.
> """
>
>         Well, the code does use the term "consumes"
>
>         And down near the bottom (line 980 or so; this is a section that
> does
> multiple passes for special cases)
> """
>             # work with a copy of the story, since it is consumed
>             tempStory = story[:]
>             self.build(tempStory, **buildKwds)
>             #self.notify('debug',None)
> """
>

Well, the official user guide (
https://www.reportlab.com/docs/reportlab-userguide.pdf ) only uses the word
"consume" in section "5.5 Frames", but it does not imply that a story
cannot be reused for generating multiple documents. It could also mean that
each document builder consumes each Flowable only once. So I still think
that this behaviour is undocumented.

It is very interesting that they use story[:] to make a swallow copy for
multiple passes. It must work in that particular case (e.g. when you build
the same document multiple times), but it surely does not work when you
build different documents using the same story (throws a LayoutError).


More information about the Python-list mailing list