[reportlab-users] Generating PDF From DB Query
CLIFFORD ILKAY
reportlab-users@reportlab.com
Tue, 10 Aug 2004 02:50:52 -0400
Hello all,
I am using the more complex recipe at
<http://wiki.w4py.org/pdfcreationwithreportlab.html>. I have that example
working but there was one mistake in the code. The last line should be
buffer.close(), not pdf.close(). Anyway, now I am trying to populate the
table from the result of a SQLObject <http://sqlobject.org> query like so:
people = Person.select(orderBy=Person.q.lastName)
tdata = []
row = []
for thePerson in people:
row = [thePerson.firstName, thePerson.lastName]
tdata.append(row)
t = Table(tdata, colwidths, rowheights)
t.setStyle(GRID_STYLE)
Story.append(t)
When I hit the page that contains the above code fragment, I get the
following error. Does anyone have any idea how I can get this working?
Traceback (most recent call last):
File "WebKit/Application.py", line 415, in dispatchRequest
File "WebKit/Application.py", line 567, in handleGoodURL
File "WebKit/Application.py", line 776, in respond
File "WebKit/Transaction.py", line 105, in respond
File "WebKit/HTTPServlet.py", line 38, in respond
File "WebKit/Page.py", line 34, in respondToGet
File "WebKit/Page.py", line 73, in _respond
File "/home/cilkay/ww/ww/pdfgenTest.py", line 96, in writeHTML
response.setHeader( 'Content-type', 'application/pdf' )
File "/usr/lib/python2.3/site-packages/reportlab/platypus/tables.py",
line 153, in __init__
raise ValueError, "%s data error - %d rows in data but %d in grid" %
(self.identity(),nrows, len(rowHeights))
File "/usr/lib/python2.3/site-packages/reportlab/platypus/tables.py",
line 192, in identity
cv = self._cellvalues
AttributeError: Table instance has no attribute '_cellvalues'
Regards,
Clifford Ilkay
Dinamis Corporation
3266 Yonge Street, Suite 1419
Toronto, Ontario
Canada M4N 3P6
Tel: 416-410-3326