Commit 3b785e4d authored by Barry Warsaw's avatar Barry Warsaw

checkOldRevisionPacked(): Use _dostoreNP(): to avoid the double

pickling
parent 993fccdc
......@@ -36,11 +36,6 @@ class PackableStorage:
self._cache[obj.getoid()] = obj
return obj
# Override StorageTestBase's method, since we're generating the pickles
# in this class explicitly.
def _massagedata(self, data):
return data
def checkOldRevisionPacked(self):
# The initial revision has an object graph like so:
# o1 -> o2 -> o3
......@@ -60,16 +55,17 @@ class PackableStorage:
return s.getvalue()
p1, p2, p3 = map(dumps, (o1, o2, o3))
# Now commit these objects
revid1 = self._dostore(oid=o1.getoid(), data=p1)
revid2 = self._dostore(oid=o2.getoid(), data=p2)
revid3 = self._dostore(oid=o3.getoid(), data=p3)
revid1 = self._dostoreNP(oid=o1.getoid(), data=p1)
revid2 = self._dostoreNP(oid=o2.getoid(), data=p2)
revid3 = self._dostoreNP(oid=o3.getoid(), data=p3)
# Record this moment in history so we can pack everything before it
t0 = time.time()
# Now change the object graph to look like so:
# o1 -> o3
# and note that o2 is no longer referenced
o1.object = o3
revid11 = self._dostore(oid=o1.getoid(), revid=revid1, data=dumps(o1))
p11 = dumps(o1)
revid11 = self._dostoreNP(oid=o1.getoid(), revid=revid1, data=p11)
# Pack away transaction 2
self._storage.pack(t0, referencesf)
# Now, objects 1 and 3 should exist, but object 2 should have been
......@@ -83,11 +79,11 @@ class PackableStorage:
data, revid = self._storage.load(o1.getoid(), '')
assert revid == revid11
from ZODB import utils
assert loads(loads(data)).getoid() == o1.getoid()
assert loads(data).getoid() == o1.getoid()
# Get object 3
data, revid = self._storage.load(o3.getoid(), '')
assert revid == revid2
assert loads(loads(data)).getoid() == o3.getoid()
assert loads(data).getoid() == o3.getoid()
# Object 2 should fail
self.assertRaises(KeyError,
self._storage.load, o2.getoid(), '')
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