[Grok-dev] Re: model not getting persisted

Martijn Faassen faassen at startifact.com
Fri Mar 23 07:24:29 EDT 2007


Lennart Regebro wrote:
> On 3/23/07, Kevin Teague <kevin at bud.ca> wrote:
>> The first case assigns x as a class attribute. The second case
>> assigns x as an instance attribute. The ZODB only persists instance
>> attributes - as far as I know?
> 
> Yup.
> 
>> class attributes are bound to the class itself, and not a particular
>> instance.
> 
> And hence will be reinitialized every time you restart Zope. So this
> behaviour is as it "should" be.
> 
>> Personally, I do not use class attributes as defaults for instance
>> attributes, but YMMV.
> 
> I do, especially when the attribute is now, for BBB.

You'd still want to avoid it. It's a good one for the tutorial to at 
least briefly mention, and we need a page on zodb.zope.org. :)

Regards,

Martijn



More information about the Grok-dev mailing list