Frank Burkhardt wrote: > how does Zope decide, if a persistent object is modified? > > What I'm interested in: > > Does > > myobject._foo='bar' > delattr(myobject,'_foo')
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 this. 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 >>> some_persistent_obj.alist.append(1) >>> 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.alist.append(2) >>> some_persistent_obj._p_changed = True >>> transaction.commit() 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. :) Philipp _______________________________________________ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users