[Zodb-checkins] CVS: StandaloneZODB/ZODB/tests - StorageTestBase.py:1.15

Jeremy Hylton jeremy@zope.com
Fri, 25 Jan 2002 12:30:43 -0500


Update of /cvs-repository/StandaloneZODB/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv9189

Modified Files:
	StorageTestBase.py 
Log Message:
Guarantee that _dostore() does not leave a transaction in progress.

Put the tpc_begin() -> tpc_finish() in a try/except.  If an error
occurs, abort the current transaction and re-raise the error.

It appears that some storages (well, only Standby Storage) has trouble
shutting down if a transaction is in progress.


=== StandaloneZODB/ZODB/tests/StorageTestBase.py 1.14 => 1.15 ===
         if description is not None:
             t.description = description
-        self._storage.tpc_begin(t)
-        # Store an object
-        r1 = self._storage.store(oid, revid, data, version, t)
-        # Finish the transaction
-        r2 = self._storage.tpc_vote(t)
-        revid = handle_serials(oid, r1, r2)
-        self._storage.tpc_finish(t)
+        try:
+            self._storage.tpc_begin(t)
+            # Store an object
+            r1 = self._storage.store(oid, revid, data, version, t)
+            # Finish the transaction
+            r2 = self._storage.tpc_vote(t)
+            revid = handle_serials(oid, r1, r2)
+            self._storage.tpc_finish(t)
+        except:
+            self._storage.tpc_abort(t)
+            raise
         return revid
         
     def _dostoreNP(self, oid=None, revid=None, data=None, version=None,