Skip to content

Commit

Permalink
Per @jimfulton, handle_all_serials shouldn't be sniffying in ZODB5, s…
Browse files Browse the repository at this point in the history
…o try that.
  • Loading branch information
jamadden committed Jul 11, 2016
1 parent f5f670c commit 71b6239
Showing 1 changed file with 10 additions and 26 deletions.
36 changes: 10 additions & 26 deletions src/ZODB/tests/StorageTestBase.py
Expand Up @@ -102,41 +102,28 @@ def zodb_unpickle(data):
return inst

def handle_all_serials(oid, *args):
"""Return dict of oid to serialno from store() and tpc_vote().
Raises an exception if one of the calls raised an exception.
The storage interface got complicated when ZEO was introduced.
Any individual store() call can return None or a sequence of
2-tuples where the 2-tuple is either oid, serialno or an
exception to be raised by the client.
The original interface just returned the serialno for the
object.
"""
Return dict of oid to serialno from store() and tpc_vote().
The updated multi-commit API returns nothing from store(), and
returns a sequence of resolved oids from tpc_vote.
This is pointless with IMultiCommitStorage.
"""
d = {}
for arg in args:
if isinstance(arg, bytes):
d[oid] = arg
elif arg:
if arg: # store() will have passed us None
for t in arg:
if isinstance(t, bytes):
# This will be the tid returned by tpc_finish.
pass
else:
oid, serial = t
if not isinstance(serial, bytes):
raise serial # error from ZEO server
d[oid] = serial
assert isinstance(t, bytes)
# This will be the tid returned by tpc_finish.
return d

def handle_serials(oid, *args):
"""Return the serialno for oid based on multiple return values.
A helper for function _handle_all_serials().
This is pointless with IMultiCommitStorage.
"""
return handle_all_serials(oid, *args).get(oid)

Expand Down Expand Up @@ -194,10 +181,7 @@ def _dostore(self, oid=None, revid=None, data=None,
r1 = self._storage.store(oid, revid, data, '', t)
# Finish the transaction
r2 = self._storage.tpc_vote(t)
revid = handle_serials(oid, r1, r2)
serial = self._storage.tpc_finish(t)
if serial is not None and revid is None:
revid = serial
revid = self._storage.tpc_finish(t)
except:
self._storage.tpc_abort(t)
raise
Expand Down

0 comments on commit 71b6239

Please sign in to comment.