[ZODB-Dev] conflict resolution for PersistentList

Dieter Maurer dieter at handshake.de
Fri May 21 17:24:25 EDT 2004


Diez B. Roggisch wrote at 2004-5-21 13:22 +0200:
>after finding that my ConflictError was suppressed by a bad designed exception 
>handler, I now want to implement a _p_resolveConflict method.
>
>I implemented it, but can't work with the passed state. It looks like this:
>
>>>> print oldState
>{'items': PR(1079757676 ('\x00\x00\x00\x00\x00\x00\x00\x02', <class 
>'persistent.list.PersistentList'>)), 'name': 'father'}
>
>
>I want to iterate over the items-lists and merge them properly. However, I 
>can't access the items as list - its not iterable.

The "states" handled by "_p_resolveConflict" are
the pickles for your objects are stored by the ZODB storage.
Usually, they are dicts with the object attributes.

Note that persistent subobjects are represented by
PersistentReferences (the "PR" above). These are *NOT*
the subobjects themselves but just references.
You cannot access the subobjects themselves during
conflict resolution.


That said, to resolve conflicts in "PersistentList",
you must give "PersistentList" a "_p_resolveConflict".
Your conflict resolution is one level too high (above
"PersistentList").

-- 
Dieter



More information about the ZODB-Dev mailing list