[reportlab-users] Problem with a class derived from Table
shawn a
boris317 at gmail.com
Tue Jan 22 14:11:38 EST 2008
Thanks a lot Tim. I can now stop banging my head against my not so soft wall ;)
On Jan 22, 2008 1:24 PM, Tim Roberts <timr at probo.com> wrote:
> shawn a wrote:
> > I have a custom table class whose base is Table. When i pass in data
> > rows and the table can render itself on ONE page there is no issue.
> > But when i pass in a larger data rows list that need to split onto
> > other pages i get an exception.
> >
> > For the purpose of this email I've stripped the custom table class down to this:
> >
> > from reportlab.platypus import Table
> > class MyTable(Table):
> > def __init__(self,data,**kw):
> > Table.__init__(self,data,**kw)
> >
> > then in my code
> >
> > t = MyTable(data,style=s[0])
> >
> > I am getting the following exception when the table needs to splitByRows:
> > Traceback (most recent call last):
> > ... File "/usr/lib/python2.4/site-packages/reportlab/platypus/tables.py",
> > line 860, in _splitRows
> > splitByRow=splitByRow)
> > TypeError: __init__() takes exactly 2 non-keyword arguments (4 given)
> >
> >
> > To recap my custom table class throws the above exception if the list
> > data is to large and the table needs to split across pages. It works
> > fine if the table can be rendered onto one page
> > OR i use the Table class exclusively:(like so)
> > t = Table(data,style=s[0])
> >
>
> Right. This seems pretty clear. The statement that explodes, line 860
> in tables.py, is calling the Table constructor, but it's passing some of
> the arguments positionally and some by keyword. Your derived class
> assumes that all of the arguments, except the first, will always be by
> keyword. You should be able to fix this via something like this:
>
> class MyTable(Table):
> def __init__( self, data, *pos, **kw ):
> Table.__init__(self, data, *pos, **kw )
>
> --
> Tim Roberts, timr at probo.com
> Providenza & Boekelheide, Inc.
>
> _______________________________________________
> reportlab-users mailing list
> reportlab-users at reportlab.com
> http://two.pairlist.net/mailman/listinfo/reportlab-users
>
More information about the reportlab-users
mailing list