Woohoo!

This is precisely the advice I needed.

I think where I got tripped up is that I rarely use class attributes
outside of Zope (setting everything up in __init__), so I actually
stopped treating them as class attributes, and pretended they were
simply part of the initilization.

I think I'm going to examine all my code this morning, see if I'm
sinning in this fashion anywhere else.

Thanks Chris, and everyone else who replied.

Alec

On 9/26/05, Chris Withers <[EMAIL PROTECTED]> wrote:
> Alec Munro wrote:
> > class SomeObj:
> >     some_dictionary = PersistentDict({})
>
> ouch, never use mutables for class attributes, for exactly the reasons
> you've found.
>
> two points:
>
> 1. the dict will get newly created every time this code runs, ie: each
> time Zope starts.
>
> 2. the object is never "seated" into the ZODB. It's an attribute of the
> class, not any instance of the class, and it's only instances of the
> class that are persisted by zodb.
>
> cheers,
>
> Chris
>
> --
> Simplistix - Content Management, Zope & Python Consulting
>             - http://www.simplistix.co.uk
>
_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to