[reportlab-users] How to inherit LinePlot class and add attributes?

Oliver Bleutgen reportlab-users@reportlab.com
Wed, 17 Sep 2003 20:11:49 +0200


reportlab@sarcastic-horse.com wrote:

> Hi-
> 
> I'm working on a time-series line plot.  I want to add an attribute to the
> LinePlot class, so I tried to inherit the class and just add a few new
> attributes.
> 
> However, the whole thing didn't work, as you can tell here:
> [...]
> 
> Traceback (most recent call last):
>   File "<pyshell#42>", line 1, in -toplevel-
>     ts = timeseriesLinePlot()
>   File "<pyshell#41>", line 4, in __init__
>     self.startdate = None
>   File "c:\python23\lib\reportlab\graphics\widgetbase.py", line 50, in
> __setattr__
>     validateSetattr(self,name,value)
>   File "c:\python23\lib\reportlab\lib\attrmap.py", line 81, in
> validateSetattr
>     raise AttributeError, "Illegal attribute '%s' in class %s" % (name,
> obj.__class__.__name__)
> AttributeError: Illegal attribute 'startdate' in class timeseriesLinePlot
> 
> 
> 
> What am I doing wrong?  I just want to be able to set the start and dates
> of my chart. as attributes of the chart itself.
> 
> I realize that this probably should occur at the xAxis level, rather than
> at the lineplot level, but I'm going to worry about that issue later.

Search for shapeChecking in the Graphics Guide.
What happens is that some base class of LinePlot has overridden 
__setattr__ in order to prohibit setting arbitrary attributes to its 
instances.

import reportlab.rl_config
reportlab.rl_config.shapeChecking = 0

should help here.

cheers,
oliver