Commit 2470e3fa authored by Jeremy Hylton's avatar Jeremy Hylton

Fix handling of ZEO exceptions. (Merge from recovery branch.)

1. The exception is in serial, not arg.
2. Must call handle_serials() before tpc_finish(), because
   handle_serials() may raise an exception that causes the transaction
   to abort.
parent c105cace
...@@ -89,7 +89,7 @@ def handle_all_serials(oid, *args): ...@@ -89,7 +89,7 @@ def handle_all_serials(oid, *args):
else: else:
for oid, serial in arg: for oid, serial in arg:
if not isinstance(serial, types.StringType): if not isinstance(serial, types.StringType):
raise arg raise serial # error from ZEO server
d[oid] = serial d[oid] = serial
return d return d
...@@ -107,16 +107,17 @@ def import_helper(name): ...@@ -107,16 +107,17 @@ def import_helper(name):
class StorageTestBase(unittest.TestCase): class StorageTestBase(unittest.TestCase):
# XXX It would be simpler if concrete tests didn't need to extend
# setUp() and tearDown().
def setUp(self): def setUp(self):
# You need to override this with a setUp that creates self._storage # You need to override this with a setUp that creates self._storage
self._transaction = Transaction()
self._storage = None self._storage = None
def _close(self): def _close(self):
# You should override this if closing your storage requires additional # You should override this if closing your storage requires additional
# shutdown operations. # shutdown operations.
if self._transaction:
self._transaction.abort()
if self._storage is not None: if self._storage is not None:
self._storage.close() self._storage.close()
...@@ -157,8 +158,9 @@ class StorageTestBase(unittest.TestCase): ...@@ -157,8 +158,9 @@ class StorageTestBase(unittest.TestCase):
r1 = self._storage.store(oid, revid, data, version, t) r1 = self._storage.store(oid, revid, data, version, t)
# Finish the transaction # Finish the transaction
r2 = self._storage.tpc_vote(t) r2 = self._storage.tpc_vote(t)
revid = handle_serials(oid, r1, r2)
self._storage.tpc_finish(t) self._storage.tpc_finish(t)
return handle_serials(oid, r1, r2) return revid
def _dostoreNP(self, oid=None, revid=None, data=None, version=None, def _dostoreNP(self, oid=None, revid=None, data=None, version=None,
user=None, description=None): user=None, description=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