[reportlab-users] error in tables.py (rl 1.21.2)
William Dode
wilk at flibuste.net
Mon Jul 14 07:03:52 EDT 2008
On 14-07-2008, Robin Becker wrote:
> William Dode wrote:
>> Hi,
>>
>> I've a random error on a table, i mean that it depends of the datas and
>> so it's difficult to reproduce...
>>
>> It raise :
>>
>> eportlab.platypus.tables:1103 in _getFirstPossibleSplitRowPosition
>> << for rh in self._rowHeights:
>> if h+rh>availHeight:
>> break
>> if not impossible.has_key(n):>> if h+rh>availHeight:
>>
>> TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'
>>
>> in fact rh is None and self._rowHeights = [None, None, None]
>>
>> I could resolve the problem by adding rh = rh or 0 but i don't know
>> why...
>>
>> Any idea if i do something wrong or if it's a know bug ?
>>
>> thx
>>
>
> I'm not certain; we certainly have tests which have one or more rowheights set
> as None. Have you got a simple example?
It's difficult because it only append somes times on the middle of
a long report...
But i catch it !
You'll see that i use LongTable even if they are not long, because i use
a generic library.
from reportlab.platypus import BaseDocTemplate, Frame, Paragraph, NextPageTemplate, PageBreak, PageTemplate, Spacer, KeepTogether, Flowable
from reportlab.lib.pagesizes import A4, landscape, portrait, cm
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.enums import TA_LEFT, TA_CENTER
from reportlab.lib import colors
from reportlab.platypus.tables import TableStyle, LongTable, Table
f=open('/tmp/t.pdf','w')
frame = Frame(2 * cm, 2 * cm , A4[0] - 4 * cm, A4[1] - 6*cm)
doc = BaseDocTemplate(f, pagesize=A4)
doc.addPageTemplates(PageTemplate('i',frame))
style_para = getSampleStyleSheet()['Normal']
style_para.spaceAfter = 12
elements = []
for z in (3,6,3,5,12,7,3,4,6,3,8):
elements.append( Paragraph('toto',style_para))
elements.append(LongTable([('x') for x in range(z)], repeatRows=1))
doc.build(elements)
--
William Dodé - http://flibuste.net
Informaticien indépendant
More information about the reportlab-users
mailing list