Commit 7de13cce authored by Barry Warsaw's avatar Barry Warsaw

zodb_pickle(): Give the Pickler a persistent_id function so that it

acts more like what happens when you commit new object revisions using
the higher level interface.
parent 26fb4200
...@@ -37,8 +37,12 @@ ZERO = '\0'*8 ...@@ -37,8 +37,12 @@ ZERO = '\0'*8
def zodb_pickle(obj): def zodb_pickle(obj):
"""Create a pickle in the format expected by ZODB.""" """Create a pickle in the format expected by ZODB."""
def persistent_id(obj):
return getattr(obj, '_p_oid', None)
f = StringIO() f = StringIO()
p = Pickler(f, 1) p = Pickler(f, 1)
p.persistent_id = persistent_id
klass = obj.__class__ klass = obj.__class__
assert not hasattr(obj, '__getinitargs__'), "not ready for constructors" assert not hasattr(obj, '__getinitargs__'), "not ready for constructors"
args = None args = None
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment