Frank Burkhardt wrote:
> how does Zope decide, if a persistent object is modified?
> What I'm interested in:
del myobject._foo :)
> make Zope create a new version of the 'myobject' in zodb?
Yes. Persistent objects are regarded modified when
a) they have either received a new attribute,
b) or an old attribute has been set to a new value,
c) or an attribute has been deleted.
Attributes starting with _v_ are considered volatile and won't count in
Note that a) through c) above specifically don't mention the changes
inside an attribute. Consider this:
>>> some_persistent_obj.alist = 
>>> transaction.commit() # some_persistent_obj will be saved
>>> transaction.commit() # nothing happens because
# some_persistent_obj itself
# hasn't changed
The workaround is to either make the 'alist' attribute a persisten
object of its own (e.g. a PersistentList). That would mean it gets its
own pickle and is stored independently of 'some_persistent_object'. This
is usually preferrable for large lists or dicts.
Another workaround is to explicitly mark 'some_persistent_obj' as changed:
>>> some_persistent_obj._p_changed = True
All of this is sort of explained in my book, but Gary Poster has
convinced me that it wasn't explained well enough. This will be fixed. :)
Zope3-users mailing list