[reportlab-users] Crashing when table goes over a page

Garth Kidd reportlab-users@reportlab.com
Mon, 28 Jul 2003 17:23:45 +1000


> > My problem is that the Apache script I'm writing becomes non=20
> > responsive if the data I try to put into a table goes over a page.
>=20
> I'm seeing the same thing here, with Python consuming as much
> CPU and memory as it can get (I had to terminate it when it=20
> hit 512MB). Setting table.canSplit doesn't help.=20

Below is the smallest code with which I can reproduce the problem. It's
surprisingly fragile around the string in the fourth column; even =
changing
POWER_SUPPLY_DEGRADED to PPPPP_SUPPLY_DEGRADED prevents the problem from
occurring.=20

Can anyone more familiar with the ReportLab engine nut this one out? I =
don't
understand ReportLab internals enough to figure it out in the debugger.

Regards,
Garth.


from reportlab.platypus import SimpleDocTemplate, Paragraph, Table,
TableStyle
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.lib import colors

def tableOfDoom(rows):=20
    td =3D []
    td.append(['hostname', 'timestamp', 'case', 'subject'])
    for rowNum in range(rows):=20
        td.append(['parrot',=20
                   '2003/01/01 13:00',=20
                   '-',=20
                   'Power Supply 2 is powered off
POWER_SUPPLY_DEGRADED!!!'])
    table =3D Table(td, repeatRows=3D1)
    return table

def buildTableOfDoom(rows):=20
    fn =3D "tableOfDoom-%d.pdf" % rows
    print "Building %s (Table of Doom with %d rows)..." % (fn, rows)
    doc =3D SimpleDocTemplate(fn)
    styles =3D getSampleStyleSheet()
    doc.build([tableOfDoom(rows)])

if __name__ =3D=3D '__main__':=20
    for rows in range(5, 46, 5):=20
        buildTableOfDoom(rows)