[reportlab-users] Infinite loop when table with Paragraph overflows a page (now with
the Test!)
David Fraser
reportlab-users@reportlab.com
Fri, 24 Oct 2003 13:29:23 +0200
This is a multi-part message in MIME format.
--------------060908090107030707020109
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Hi
More table layout issues ...
We've had trouble with the layout of a table with a large cell that
doesn't fit in the page.
If I run the attached test with numtests=6, the python process starts
using up loads of memory and CPU, eventually growing to at least 350MB
We don't neccessarily need to display all the data (as it doesn't fit),
but it would be nice if there was some way to trap this condition and
either (prefarably) truncate it or at least raise an error.
The test basically produces a table with three columns, one of which has
a paragraph in it with lots of text.
Successive tables with more and more text are produced. If you stop off
at numtests=5 (the default value), everything is fine.
Any comments on where this might be in the code or how we can avoid it?
Thanks
David
PS Sorry, forgot to attach the test last time
--------------060908090107030707020109
Content-Type: text/plain;
name="test_platypus_tables_pagebreak.py"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="test_platypus_tables_pagebreak.py"
#!/bin/env python
#copyright ReportLab Inc. 2000
#see license.txt for license details
#history http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/reportlab/platypus/test/testtables.py?cvsroot=reportlab
#$Header: /cvsroot/reportlab/reportlab/test/test_platypus_tables.py,v 1.3 2002/07/24 19:56:38 andy_robinson Exp $
__version__=''' $Id: test_platypus_tables.py,v 1.3 2002/07/24 19:56:38 andy_robinson Exp $ '''
__doc__='Test script for reportlab.tables'
from reportlab.test import unittest
from reportlab.test.utils import makeSuiteForClasses
from reportlab.platypus import Spacer, SimpleDocTemplate, Table, TableStyle, Paragraph
from reportlab.lib.units import inch
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.lib import colors
import sys
numtests = 5
def getMuchText(i):
return "much text " * i * 20
def getTable(i):
style = getSampleStyleSheet()["Normal"]
rows = (('a', Paragraph(getMuchText(i), style), 'b'),)
return Table(rows, colWidths=[99,99,99])
def getstyle(i):
return TableStyle([])
def run():
doc = SimpleDocTemplate('test_platypus_tables_pagebreak.pdf', pagesize=(8.5*inch, 11*inch), showBoundary=1)
lst = []
for i in range(numtests + 1):
style = getstyle(i)
t = getTable(i)
t.setStyle(style)
lst.append(t)
lst.append(Spacer(0,12))
doc.build(lst)
class TablesTestCase(unittest.TestCase):
"Make documents with tables"
def test0(self):
"Make a document full of tables"
run()
def makeSuite():
return makeSuiteForClasses(TablesTestCase)
#noruntests
if __name__ == "__main__":
if len(sys.argv) > 1:
global numtests
numtests = int(sys.argv[1])
unittest.TextTestRunner().run(makeSuite())
--------------060908090107030707020109--