[Zope3-Users] Disappearing dictionary. Upon restart, dictionary resets.

Alec Munro alecmunro at gmail.com
Mon Sep 26 07:02:16 EDT 2005


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 <chris at simplistix.co.uk> 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
>


More information about the Zope3-users mailing list