[ZODB-Dev] modifying tree under root and save ?!

Sean Upton sdupton at gmail.com
Mon Dec 9 20:55:08 CET 2013


On Mon, Dec 9, 2013 at 10:19 AM, Tamer Higazi <tameritoke2 at arcor.de> wrote:
> Is there a way, to change the ZODB keys subcontent without to copy the
> entire entry in the memory ?!

You should -- as suggested previously -- for mutable collections, use
PersistentDict and PersistentList, otherwise insertions, deletions,
and (for dict) reassigning values will not be detected as changes.

The workaround if you absolutely must use a mutable Python built-in
list or dict (as an attribute of an object subclassing Persistent), is
to set myobject._p_changed = True for any object whose list or dict
attributes have changes -- but really, you should just use
PersistentDict, PersistentList, or BTrees equivalents.

Additional reading:

http://www.zodb.org/en/latest/documentation/guide/prog-zodb.html#modifying-mutable-objects

http://stackoverflow.com/questions/5704589/zodb-not-able-to-commit


Sean


More information about the ZODB-Dev mailing list