[Zope] Re: Adding new _properties

Maik Jablonski maik.jablonski at uni-bielefeld.de
Mon Mar 29 10:19:33 EST 2004


Serg wrote:
> I had product with below properties:
> 
> class easyArticle(SimpleItem.SimpleItem):
>     _properties = (
>         {'id':'author', 'type':'string', 'mode':'w'}
>     )
> ...
> 
> I inputted some objects of this product.
> 
> Later I added some properties:
> class easyArticle(SimpleItem.SimpleItem):
>     _properties = (
>         {'id':'author', 'type':'string', 'mode':'w'},
>         {'id':'n1','type':'float', 'mode':'w'},
>         {'id':'n2','type':'float', 'mode':'w'}
>     )
> ...
> 
> After that, I cannt read old objects of this class. Zope write:
> Site Error
> An error was encountered while publishing this resource.
> Error Type: AttributeError
> Error Value: n1
> 
> How can I solve this problem?

Two possibilities:

1) Create an update-method, which you call on each object and which adds the
required attribute (self.n1=0.0 etc.)

2) Add the additional (better: all) properties as class-attributes.

Something like:

   class easyArticle(SimpleItem.SimpleItem):
       id=''
       n1=0.0
       n2=0.0
       _properties = ...

Cheers, Maik




More information about the Zope mailing list