[Zodb-checkins] CVS: Zope3/src/ZODB/tests - testmvcc.py:1.12 testZODB.py:1.25 testTransaction.py:1.20 testFileStorage.py:1.39 testConnection.py:1.9 VersionStorage.py:1.31 TransactionalUndoVersionStorage.py:1.19 TransactionalUndoStorage.py:1.41 Synchronization.py:1.11 StorageTestBase.py:1.34 RevisionStorage.py:1.7 RecoveryStorage.py:1.13 ReadOnlyStorage.py:1.11 PackableStorage.py:1.38 MTStorage.py:1.16 IteratorStorage.py:1.20 HistoryStorage.py:1.15 ConflictResolution.py:1.16 BasicStorage.py:1.29

Jeremy Hylton jeremy at zope.com
Wed Mar 31 22:57:31 EST 2004


Update of /cvs-repository/Zope3/src/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv23866/src/ZODB/tests

Modified Files:
	testmvcc.py testZODB.py testTransaction.py testFileStorage.py 
	testConnection.py VersionStorage.py 
	TransactionalUndoVersionStorage.py TransactionalUndoStorage.py 
	Synchronization.py StorageTestBase.py RevisionStorage.py 
	RecoveryStorage.py ReadOnlyStorage.py PackableStorage.py 
	MTStorage.py IteratorStorage.py HistoryStorage.py 
	ConflictResolution.py BasicStorage.py 
Log Message:
Merge the jeremy-txn-branch to the head.

This branch introduces a new transaction API.  The key features are:
  - top-level functions in transaction -- get(), commit(), abort() 
  - explicit transaction manager objects
  - Transaction objects are used for exactly one transaction
  - support for transaction synchronizers

The changes here are still provisional, but we want to get them off an
obscure branch and onto the head for further development.


=== Zope3/src/ZODB/tests/testmvcc.py 1.11 => 1.12 ===
--- Zope3/src/ZODB/tests/testmvcc.py:1.11	Fri Mar 12 16:47:35 2004
+++ Zope3/src/ZODB/tests/testmvcc.py	Wed Mar 31 22:56:57 2004
@@ -41,8 +41,9 @@
 setLocalTransaction() method to make sure that the connections act
 independently, even though they'll be run from a single thread.
 
->>> cn1 = db.open()
->>> txn1 = cn1.setLocalTransaction()
+>>> import transaction
+>>> tm1 = transaction.TransactionManager()
+>>> cn1 = db.open(txn_mgr=tm1)
 
 The test will just use some MinPO objects.  The next few lines just
 setup an initial database state.
@@ -51,12 +52,12 @@
 >>> r = cn1.root()
 >>> r["a"] = MinPO(1)
 >>> r["b"] = MinPO(1)
->>> txn1.commit()
+>>> tm1.get().commit()
 
 Now open a second connection.
 
->>> cn2 = db.open()
->>> txn2 = cn2.setLocalTransaction()
+>>> tm2 = transaction.TransactionManager()
+>>> cn2 = db.open(txn_mgr=tm2)
 
 Connection high-water mark
 --------------------------
@@ -104,7 +105,7 @@
 
 >>> r1 = cn1.root()
 >>> r1["a"].value = 2
->>> cn1.getTransaction().commit()
+>>> tm1.get().commit()
 >>> txn = db.lastTransaction()
 
 The second connection has its high-water mark set now.
@@ -141,7 +142,7 @@
 commit the transaction.
 
 >>> r2["a"].value = 3
->>> txn2.commit()
+>>> tm2.get().commit()
 Traceback (most recent call last):
  ...
 ConflictError: database conflict error (oid 0000000000000001, class ZODB.tests.MinPO.MinPO)
@@ -155,9 +156,7 @@
 
 >>> r1 = cn1.root()
 >>> r1["a"].value = 3
->>> txn1 is cn1.getTransaction()
-True
->>> cn1.getTransaction().commit()
+>>> tm1.get().commit()
 >>> txn = db.lastTransaction()
 >>> cn2._txn_time == txn
 True
@@ -165,7 +164,7 @@
 >>> r2["b"].value = r2["a"].value + 1
 >>> r2["b"].value
 3
->>> txn2.commit()
+>>> tm2.get().commit()
 >>> print cn2._txn_time
 None
 
@@ -185,7 +184,7 @@
 >>> cn1.sync()
 >>> r1["a"].value = 0
 >>> r1["b"].value = 0
->>> cn1.getTransaction().commit()
+>>> tm1.get().commit()
 
 >>> cn2.sync()
 >>> r2["a"].value
@@ -206,7 +205,7 @@
 ...     cn1.sync()
 ...     r1["a"].value = 0
 ...     r1["b"].value = 0
-...     cn1.getTransaction().commit()
+...     tm1.get().commit()
 ...     cn2.sync()
 ...     r2["b"].value = 1
 ...     cn2.getTransaction().commit()
@@ -217,7 +216,7 @@
 >>> r1["b"].value
 0
 >>> r1["a"].value = 1
->>> cn1.getTransaction().commit()
+>>> tm1.get().commit()
 >>> r1["b"]._p_state
 -1
 
@@ -280,14 +279,13 @@
 
 >>> ts = TestStorage()
 >>> db = DB(ts)
->>> cn1 = db.open()
->>> txn1 = cn1.setLocalTransaction()
+>>> cn1 = db.open(txn_mgr=tm1)
 >>> r1 = cn1.root()
 >>> r1["a"] = MinPO(0)
 >>> r1["b"] = MinPO(0)
->>> cn1.getTransaction().commit()
+>>> tm1.get().commit()
 >>> r1["b"].value = 1
->>> cn1.getTransaction().commit()
+>>> tm1.get().commit()
 >>> cn1.cacheMinimize()  # makes everything in cache a ghost
 
 >>> oid = r1["b"]._p_oid
@@ -318,12 +316,11 @@
 
 >>> ts = TestStorage()
 >>> db = DB(ts)
->>> cn1 = db.open()
->>> txn1 = cn1.setLocalTransaction()
+>>> cn1 = db.open(txn_mgr=tm1)
 >>> r1 = cn1.root()
 >>> r1["a"] = MinPO(0)
 >>> r1["b"] = MinPO(0)
->>> cn1.getTransaction().commit()
+>>> tm1.get().commit()
 >>> cn1.cacheMinimize()  # makes everything in cache a ghost
 
 >>> oid = r1["b"]._p_oid


=== Zope3/src/ZODB/tests/testZODB.py 1.24 => 1.25 ===
--- Zope3/src/ZODB/tests/testZODB.py:1.24	Tue Mar  2 11:46:35 2004
+++ Zope3/src/ZODB/tests/testZODB.py	Wed Mar 31 22:56:57 2004
@@ -16,8 +16,10 @@
 import ZODB
 import ZODB.FileStorage
 from ZODB.POSException import ReadConflictError, ConflictError
+
 from persistent import Persistent
 from persistent.mapping import PersistentMapping
+import transaction
 
 class P(Persistent):
     pass
@@ -54,72 +56,76 @@
         self._db.close()
         self._storage.cleanup()
 
-    def checkExportImport(self, abort_it=0, dup_name='test_duplicate'):
+    def checkExportImport(self, abort_it=False):
         self.populate()
-        get_transaction().begin()
-        get_transaction().note('duplication')
-        # Duplicate the 'test' object.
         conn = self._db.open()
         try:
-            root = conn.root()
-            ob = root['test']
-            assert len(ob) > 10, 'Insufficient test data'
-            try:
-                import tempfile
-                f = tempfile.TemporaryFile()
-                ob._p_jar.exportFile(ob._p_oid, f)
-                assert f.tell() > 0, 'Did not export correctly'
-                f.seek(0)
-                new_ob = ob._p_jar.importFile(f)
-                root[dup_name] = new_ob
-                f.close()
-                if abort_it:
-                    get_transaction().abort()
-                else:
-                    get_transaction().commit()
-            except:
-                get_transaction().abort()
-                raise
+            self.duplicate(conn, abort_it)
         finally:
             conn.close()
-        get_transaction().begin()
-        # Verify the duplicate.
         conn = self._db.open()
         try:
-            root = conn.root()
-            ob = root['test']
-            try:
-                ob2 = root[dup_name]
-            except KeyError:
-                if abort_it:
-                    # Passed the test.
-                    return
-                else:
-                    raise
-            else:
-                if abort_it:
-                    assert 0, 'Did not abort duplication'
-            l1 = list(ob.items())
-            l1.sort()
-            l2 = list(ob2.items())
-            l2.sort()
-            l1 = map(lambda (k, v): (k, v[0]), l1)
-            l2 = map(lambda (k, v): (k, v[0]), l2)
-            assert l1 == l2, 'Duplicate did not match'
-            assert ob._p_oid != ob2._p_oid, 'Did not duplicate'
-            assert ob._p_jar == ob2._p_jar, 'Not same connection'
-            oids = {}
-            for v in ob.values():
-                oids[v._p_oid] = 1
-            for v in ob2.values():
-                assert not oids.has_key(v._p_oid), (
-                    'Did not fully separate duplicate from original')
-            get_transaction().commit()
+            self.verify(conn, abort_it)
         finally:
             conn.close()
 
+    def duplicate(self, conn, abort_it):
+        get_transaction().begin()
+        get_transaction().note('duplication')
+        root = conn.root()
+        ob = root['test']
+        assert len(ob) > 10, 'Insufficient test data'
+        try:
+            import tempfile
+            f = tempfile.TemporaryFile()
+            ob._p_jar.exportFile(ob._p_oid, f)
+            assert f.tell() > 0, 'Did not export correctly'
+            f.seek(0)
+            new_ob = ob._p_jar.importFile(f)
+            self.assertEqual(new_ob, ob)
+            root['dup'] = new_ob
+            f.close()
+            if abort_it:
+                get_transaction().abort()
+            else:
+                get_transaction().commit()
+        except:
+            get_transaction().abort()
+            raise
+
+    def verify(self, conn, abort_it):
+        get_transaction().begin()
+        root = conn.root()
+        ob = root['test']
+        try:
+            ob2 = root['dup']
+        except KeyError:
+            if abort_it:
+                # Passed the test.
+                return
+            else:
+                raise
+        else:
+            self.failUnless(not abort_it, 'Did not abort duplication')
+        l1 = list(ob.items())
+        l1.sort()
+        l2 = list(ob2.items())
+        l2.sort()
+        l1 = map(lambda (k, v): (k, v[0]), l1)
+        l2 = map(lambda (k, v): (k, v[0]), l2)
+        self.assertEqual(l1, l2)
+        self.assert_(ob._p_oid != ob2._p_oid)
+        self.assertEqual(ob._p_jar, ob2._p_jar)
+        oids = {}
+        for v in ob.values():
+            oids[v._p_oid] = 1
+        for v in ob2.values():
+            assert not oids.has_key(v._p_oid), (
+                'Did not fully separate duplicate from original')
+        get_transaction().commit()
+
     def checkExportImportAborted(self):
-        self.checkExportImport(abort_it=1, dup_name='test_duplicate_aborted')
+        self.checkExportImport(abort_it=True)
 
     def checkVersionOnly(self):
         # Make sure the changes to make empty transactions a no-op
@@ -159,6 +165,44 @@
         self.assert_(len(conn._cache) > 0)  # Still not flushed
         conn._setDB(self._db)  # simulate the connection being reopened
         self.assertEqual(len(conn._cache), 0)
+
+    def checkExplicitTransactionManager(self):
+        # Test of transactions that apply to only the connection,
+        # not the thread.
+        tm1 = transaction.TransactionManager()
+        conn1 = self._db.open(txn_mgr=tm1)
+        tm2 = transaction.TransactionManager()
+        conn2 = self._db.open(txn_mgr=tm2)
+        try:
+            r1 = conn1.root()
+            r2 = conn2.root()
+            if r1.has_key('item'):
+                del r1['item']
+                tm1.get().commit()
+            r1.get('item')
+            r2.get('item')
+            r1['item'] = 1
+            tm1.get().commit()
+            self.assertEqual(r1['item'], 1)
+            # r2 has not seen a transaction boundary,
+            # so it should be unchanged.
+            self.assertEqual(r2.get('item'), None)
+            conn2.sync()
+            # Now r2 is updated.
+            self.assertEqual(r2['item'], 1)
+
+            # Now, for good measure, send an update in the other direction.
+            r2['item'] = 2
+            tm2.get().commit()
+            self.assertEqual(r1['item'], 1)
+            self.assertEqual(r2['item'], 2)
+            conn1.sync()
+            conn2.sync()
+            self.assertEqual(r1['item'], 2)
+            self.assertEqual(r2['item'], 2)
+        finally:
+            conn1.close()
+            conn2.close()
 
     def checkLocalTransactions(self):
         # Test of transactions that apply to only the connection,


=== Zope3/src/ZODB/tests/testTransaction.py 1.19 => 1.20 ===
--- Zope3/src/ZODB/tests/testTransaction.py:1.19	Thu Feb 26 19:31:55 2004
+++ Zope3/src/ZODB/tests/testTransaction.py	Wed Mar 31 22:56:57 2004
@@ -11,13 +11,7 @@
 # FOR A PARTICULAR PURPOSE
 #
 ##############################################################################
-
-"""
-Revision information:
-$Id$
-"""
-
-"""
+"""Test tranasction behavior for variety of cases.
 
 I wrote these unittests to investigate some odd transaction
 behavior when doing unittests of integrating non sub transaction
@@ -42,26 +36,24 @@
     add in tests for objects which are modified multiple times,
     for example an object that gets modified in multiple sub txns.
 
+$Id$
 """
 
-from types import TupleType
 import unittest
-
-from ZODB import Transaction
+import transaction
 
 class TransactionTests(unittest.TestCase):
 
     def setUp(self):
-
-        Transaction.hosed = 0
+        self.orig_tm = transaction.manager
+        transaction.manager = transaction.TransactionManager()
         self.sub1 = DataObject()
         self.sub2 = DataObject()
         self.sub3 = DataObject()
         self.nosub1 = DataObject(nost=1)
 
     def tearDown(self):
-
-        Transaction.free_transaction()
+        transaction.manager = self.orig_tm
 
     # basic tests with two sub trans jars
     # really we only need one, so tests for
@@ -124,18 +116,12 @@
         assert self.sub1._p_jar.cabort_sub == 1
 
     def testMultipleSubTransactionCommitCommit(self):
-
-        # add it
         self.sub1.modify()
-
         get_transaction().commit(1)
 
-        # add another
         self.sub2.modify()
-
         # reset a flag on the original to test it again
         self.sub1.ctpc_finish = 0
-
         get_transaction().commit(1)
 
         # this is interesting.. we go through
@@ -150,7 +136,7 @@
 
         get_transaction().commit()
 
-        # we did an implicit sub commit, is this impl artifiact?
+        # we did an implicit sub commit, is this impl artifact?
         assert self.sub3._p_jar.ccommit_sub == 1
         assert self.sub1._p_jar.ctpc_finish > 1
 
@@ -350,7 +336,6 @@
         assert self.nosub1._p_jar.ctpc_finish == 0
         assert self.nosub1._p_jar.ccommit == 1
         assert self.nosub1._p_jar.ctpc_abort == 1
-        assert Transaction.hosed == 0
 
     def testExceptionInTpcVote(self):
 
@@ -367,7 +352,6 @@
         assert self.nosub1._p_jar.ccommit == 1
         assert self.nosub1._p_jar.ctpc_abort == 1
         assert self.sub1._p_jar.ctpc_abort == 1
-        assert Transaction.hosed == 0
 
     def testExceptionInTpcBegin(self):
         """
@@ -406,29 +390,18 @@
         except TestTxnException: pass
 
         assert self.nosub1._p_jar.ctpc_abort == 1
-        assert Transaction.hosed == 0
 
     ### More Failure modes...
     # now we mix in some sub transactions
     ###
 
     def testExceptionInSubCommitSub(self):
-        """
-        this tests exhibits some odd behavior,
-        nothing thats technically incorrect...
-
-        basically it seems non deterministic, even
-        stranger the behavior seems dependent on what
-        values i test after the fact... very odd,
-        almost relativistic.
-
-        in-retrospect this is from the fact that
-        dictionaries are used to store jars at some point
-
-        """
+        # It's harder than normal to verify test results, because
+        # the subtransaction jars are stored in a dictionary.  The
+        # order in which jars are processed depends on the order
+        # they come out of the dictionary.
 
         self.sub1.modify()
-
         get_transaction().commit(1)
 
         self.nosub1.modify()
@@ -442,24 +415,30 @@
 
         try:
             get_transaction().commit()
-        except TestTxnException: pass
-
+        except TestTxnException:
+            pass
 
-        # odd this doesn't seem to be entirely deterministic..
         if self.sub1._p_jar.ccommit_sub:
-            assert self.sub1._p_jar.ctpc_abort == 1
+            self.assertEqual(self.sub1._p_jar.ctpc_abort, 1)
         else:
-            assert self.sub1._p_jar.cabort_sub == 1
+            self.assertEqual(self.sub1._p_jar.cabort_sub, 1)
+
+        self.assertEqual(self.sub2._p_jar.ctpc_abort, 1)
+        self.assertEqual(self.nosub1._p_jar.ctpc_abort, 1)
 
         if self.sub3._p_jar.ccommit_sub:
-            assert self.sub3._p_jar.ctpc_abort == 1
+            self.assertEqual(self.sub3._p_jar.ctpc_abort, 1)
         else:
-            assert self.sub3._p_jar.cabort_sub == 1
-
-        assert self.sub2._p_jar.ctpc_abort == 1
-        assert self.nosub1._p_jar.ctpc_abort == 1
+            self.assertEqual(self.sub3._p_jar.cabort_sub, 1)
 
     def testExceptionInSubAbortSub(self):
+        # This test has two errors.  When commit_sub() is called on
+        # sub1, it will fail.  If sub1 is handled first, it will raise
+        # an except and abort_sub() will be called on sub2.  If sub2
+        # is handled first, then commit_sub() will fail after sub2 has
+        # already begun its top-level transaction and tpc_abort() will
+        # be called.
+
         self.sub1._p_jar = SubTransactionJar(errors='commit_sub')
         self.sub1.modify(nojar=1)
         get_transaction().commit(1)
@@ -482,51 +461,47 @@
         # called, then tpc_abort() should be called to abort the
         # actual transaction.  If not, then calling abort_sub() is
         # sufficient.
-        if self.sub3._p_jar.ccommit_sub == 1:
+        if self.sub3._p_jar.ccommit_sub:
             self.assertEqual(self.sub3._p_jar.ctpc_abort, 1)
         else:
             self.assertEqual(self.sub3._p_jar.cabort_sub, 1)
 
     # last test, check the hosing mechanism
 
-    def testHoserStoppage(self):
-        # XXX We should consult ZConfig to decide whether we can get into a
-        # hosed state or not.
-        return
-
-        # It's hard to test the "hosed" state of the database, where
-        # hosed means that a failure occurred in the second phase of
-        # the two phase commit.  It's hard because the database can
-        # recover from such an error if it occurs during the very first
-        # tpc_finish() call of the second phase.
-
-        for obj in self.sub1, self.sub2:
-            j = HoserJar(errors='tpc_finish')
-            j.reset()
-            obj._p_jar = j
-            obj.modify(nojar=1)
-
-        try:
-            get_transaction().commit()
-        except TestTxnException:
-            pass
-
-        self.assert_(Transaction.hosed)
-
-        self.sub2.modify()
-
-        try:
-            get_transaction().commit()
-        except Transaction.POSException.TransactionError:
-            pass
-        else:
-            self.fail("Hosed Application didn't stop commits")
+##    def testHoserStoppage(self):
+##        # It's hard to test the "hosed" state of the database, where
+##        # hosed means that a failure occurred in the second phase of
+##        # the two phase commit.  It's hard because the database can
+##        # recover from such an error if it occurs during the very first
+##        # tpc_finish() call of the second phase.
+
+##        for obj in self.sub1, self.sub2:
+##            j = HoserJar(errors='tpc_finish')
+##            j.reset()
+##            obj._p_jar = j
+##            obj.modify(nojar=1)
+
+##        try:
+##            get_transaction().commit()
+##        except TestTxnException:
+##            pass
+
+##        self.assert_(Transaction.hosed)
+
+##        self.sub2.modify()
+
+##        try:
+##            get_transaction().commit()
+##        except Transaction.POSException.TransactionError:
+##            pass
+##        else:
+##            self.fail("Hosed Application didn't stop commits")
 
 
 class DataObject:
 
     def __init__(self, nost=0):
-        self.nost= nost
+        self.nost = nost
         self._p_jar = None
 
     def modify(self, nojar=0, tracing=0):
@@ -543,7 +518,7 @@
 class BasicJar:
 
     def __init__(self, errors=(), tracing=0):
-        if not isinstance(errors, TupleType):
+        if not isinstance(errors, tuple):
             errors = errors,
         self.errors = errors
         self.tracing = tracing
@@ -557,7 +532,12 @@
         self.ccommit_sub = 0
 
     def __repr__(self):
-        return "<jar %X %s>" % (id(self), self.errors)
+        return "<%s %X %s>" % (self.__class__.__name__, id(self), self.errors)
+
+    def sortKey(self):
+        # All these jars use the same sort key, and Python's list.sort()
+        # is stable.  These two
+        return self.__class__.__name__
 
     def check(self, method):
         if self.tracing:
@@ -637,19 +617,19 @@
     transaction.interfaces.IDataManager.
 
     >>> from ZODB.tests.sampledm import DataManager
-    >>> from ZODB.Transaction import DataManagerAdapter
-    >>> t = Transaction.Transaction()
+    >>> from transaction._transaction import DataManagerAdapter
+    >>> t = transaction.Transaction()
     >>> dm = DataManager()
     >>> t.join(dm)
 
     The end result is that a data manager adapter is one of the
     transaction's objects:
 
-    >>> isinstance(t._objects[0], DataManagerAdapter)
+    >>> isinstance(t._resources[0], DataManagerAdapter)
     True
-    >>> t._objects[0]._datamanager is dm
+    >>> t._resources[0]._datamanager is dm
     True
-    
+
     """
 
 def test_suite():


=== Zope3/src/ZODB/tests/testFileStorage.py 1.38 => 1.39 ===
--- Zope3/src/ZODB/tests/testFileStorage.py:1.38	Thu Feb 26 19:31:55 2004
+++ Zope3/src/ZODB/tests/testFileStorage.py	Wed Mar 31 22:56:57 2004
@@ -11,9 +11,9 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-import ZODB.FileStorage
 import os, unittest
-from ZODB.Transaction import Transaction
+import transaction
+import ZODB.FileStorage
 from ZODB import POSException
 
 from ZODB.tests import StorageTestBase, BasicStorage, \
@@ -195,7 +195,7 @@
         # every 8000 calls.  Make sure it gets minimal coverage.
         oids = [[self._storage.new_oid(), None] for i in range(100)]
         for i in range(100):
-            t = Transaction()
+            t = transaction.Transaction()
             self._storage.tpc_begin(t)
             for j in range(100):
                 o = MinPO(j)


=== Zope3/src/ZODB/tests/testConnection.py 1.8 => 1.9 ===
--- Zope3/src/ZODB/tests/testConnection.py:1.8	Sat Mar 13 02:48:11 2004
+++ Zope3/src/ZODB/tests/testConnection.py	Wed Mar 31 22:56:57 2004
@@ -483,8 +483,6 @@
     appended to self._finished.
     """
 
-    sortKey = 'StubStorage sortKey'
-
     # internal
     _oid = 1
     _transaction = None
@@ -501,6 +499,9 @@
         oid = str(self._oid)
         self._oid += 1
         return oid
+
+    def sortKey(self):
+        return 'StubStorage sortKey'
 
     def tpc_begin(self, transaction):
         if transaction is None:


=== Zope3/src/ZODB/tests/VersionStorage.py 1.30 => 1.31 ===
--- Zope3/src/ZODB/tests/VersionStorage.py:1.30	Thu Feb 19 13:35:23 2004
+++ Zope3/src/ZODB/tests/VersionStorage.py	Wed Mar 31 22:56:57 2004
@@ -18,9 +18,10 @@
 
 import time
 
+from transaction import Transaction
+
 from ZODB import POSException
 from ZODB.serialize import referencesf
-from ZODB.Transaction import Transaction
 from ZODB.tests.MinPO import MinPO
 from ZODB.tests.StorageTestBase import zodb_unpickle, snooze
 from ZODB import DB


=== Zope3/src/ZODB/tests/TransactionalUndoVersionStorage.py 1.18 => 1.19 ===
--- Zope3/src/ZODB/tests/TransactionalUndoVersionStorage.py:1.18	Thu Feb 26 19:31:55 2004
+++ Zope3/src/ZODB/tests/TransactionalUndoVersionStorage.py	Wed Mar 31 22:56:57 2004
@@ -16,8 +16,9 @@
 
 import time
 
+import transaction
+
 from ZODB.serialize import referencesf
-from ZODB.Transaction import Transaction
 from ZODB.tests.MinPO import MinPO
 from ZODB.tests.StorageTestBase import zodb_unpickle
 
@@ -114,7 +115,7 @@
                         version=version, description='version2')
         self._x_dostore(description='create2')
 
-        t = Transaction()
+        t = transaction.Transaction()
         t.description = 'commit version'
         self._storage.tpc_begin(t)
         self._storage.commitVersion(version, '', t)


=== Zope3/src/ZODB/tests/TransactionalUndoStorage.py 1.40 => 1.41 ===
--- Zope3/src/ZODB/tests/TransactionalUndoStorage.py:1.40	Thu Feb 26 19:31:55 2004
+++ Zope3/src/ZODB/tests/TransactionalUndoStorage.py	Wed Mar 31 22:56:57 2004
@@ -18,13 +18,15 @@
 
 import time
 import types
+
+from persistent import Persistent
+from transaction import Transaction
+
 from ZODB import POSException
-from ZODB.Transaction import Transaction
 from ZODB.serialize import referencesf
 from ZODB.utils import p64
 from ZODB import DB
 
-from persistent import Persistent
 from ZODB.tests.MinPO import MinPO
 from ZODB.tests.StorageTestBase import zodb_pickle, zodb_unpickle
 


=== Zope3/src/ZODB/tests/Synchronization.py 1.10 => 1.11 ===
--- Zope3/src/ZODB/tests/Synchronization.py:1.10	Tue Feb 17 20:12:59 2004
+++ Zope3/src/ZODB/tests/Synchronization.py	Wed Mar 31 22:56:57 2004
@@ -62,7 +62,7 @@
 
 """
 
-from ZODB.Transaction import Transaction
+from transaction import Transaction
 from ZODB.POSException import StorageTransactionError
 
 VERSION = "testversion"


=== Zope3/src/ZODB/tests/StorageTestBase.py 1.33 => 1.34 ===
--- Zope3/src/ZODB/tests/StorageTestBase.py:1.33	Wed Feb 18 21:59:10 2004
+++ Zope3/src/ZODB/tests/StorageTestBase.py	Wed Mar 31 22:56:57 2004
@@ -26,9 +26,9 @@
 from cPickle import Pickler, Unpickler
 from cStringIO import StringIO
 
-from ZODB.Transaction import Transaction
-from ZODB.utils import u64
+import transaction
 
+from ZODB.utils import u64
 from ZODB.tests.MinPO import MinPO
 
 ZERO = '\0'*8
@@ -184,7 +184,7 @@
         if version is None:
             version = ''
         # Begin the transaction
-        t = Transaction()
+        t = transaction.Transaction()
         if user is not None:
             t.user = user
         if description is not None:
@@ -211,7 +211,7 @@
     def _undo(self, tid, expected_oids=None, note=None):
         # Undo a tid that affects a single object (oid).
         # XXX This is very specialized
-        t = Transaction()
+        t = transaction.Transaction()
         t.note(note or "undo")
         self._storage.tpc_begin(t)
         tid, oids = self._storage.undo(tid, t)
@@ -224,7 +224,7 @@
         return self._storage.lastTransaction()
 
     def _commitVersion(self, src, dst):
-        t = Transaction()
+        t = transaction.Transaction()
         t.note("commit %r to %r" % (src, dst))
         self._storage.tpc_begin(t)
         tid, oids = self._storage.commitVersion(src, dst, t)
@@ -233,7 +233,7 @@
         return oids
 
     def _abortVersion(self, ver):
-        t = Transaction()
+        t = transaction.Transaction()
         t.note("abort %r" % ver)
         self._storage.tpc_begin(t)
         tid, oids = self._storage.abortVersion(ver, t)


=== Zope3/src/ZODB/tests/RevisionStorage.py 1.6 => 1.7 ===
--- Zope3/src/ZODB/tests/RevisionStorage.py:1.6	Mon Dec 29 17:03:52 2003
+++ Zope3/src/ZODB/tests/RevisionStorage.py	Wed Mar 31 22:56:57 2004
@@ -16,9 +16,10 @@
 from ZODB.tests.MinPO import MinPO
 from ZODB.tests.StorageTestBase import \
      zodb_unpickle, zodb_pickle, snooze, handle_serials
-from ZODB.Transaction import Transaction
 from ZODB.utils import p64, u64
 
+import transaction
+
 ZERO = '\0'*8
 
 class RevisionStorage:
@@ -142,7 +143,7 @@
         oid = self._storage.new_oid()
         def helper(tid, revid, x):
             data = zodb_pickle(MinPO(x))
-            t = Transaction()
+            t = transaction.Transaction()
             try:
                 self._storage.tpc_begin(t, p64(tid))
                 r1 = self._storage.store(oid, revid, data, '', t)


=== Zope3/src/ZODB/tests/RecoveryStorage.py 1.12 => 1.13 ===
--- Zope3/src/ZODB/tests/RecoveryStorage.py:1.12	Thu Feb 19 13:35:23 2004
+++ Zope3/src/ZODB/tests/RecoveryStorage.py	Wed Mar 31 22:56:57 2004
@@ -13,7 +13,7 @@
 ##############################################################################
 """More recovery and iterator tests."""
 
-from ZODB.Transaction import Transaction
+from transaction import Transaction
 from ZODB.tests.IteratorStorage import IteratorDeepCompare
 from ZODB.tests.StorageTestBase import MinPO, zodb_unpickle, snooze
 from ZODB import DB


=== Zope3/src/ZODB/tests/ReadOnlyStorage.py 1.10 => 1.11 ===
--- Zope3/src/ZODB/tests/ReadOnlyStorage.py:1.10	Tue Feb 17 20:12:59 2004
+++ Zope3/src/ZODB/tests/ReadOnlyStorage.py	Wed Mar 31 22:56:57 2004
@@ -12,7 +12,7 @@
 #
 ##############################################################################
 from ZODB.POSException import ReadOnlyError, Unsupported
-from ZODB.Transaction import Transaction
+import transaction
 
 class ReadOnlyStorage:
 
@@ -47,7 +47,7 @@
     def checkWriteMethods(self):
         self._make_readonly()
         self.assertRaises(ReadOnlyError, self._storage.new_oid)
-        t = Transaction()
+        t = transaction.Transaction()
         self.assertRaises(ReadOnlyError, self._storage.tpc_begin, t)
 
         if self._storage.supportsVersions():


=== Zope3/src/ZODB/tests/PackableStorage.py 1.37 => 1.38 ===
--- Zope3/src/ZODB/tests/PackableStorage.py:1.37	Wed Mar 17 14:10:40 2004
+++ Zope3/src/ZODB/tests/PackableStorage.py	Wed Mar 31 22:56:57 2004
@@ -127,7 +127,7 @@
         try:
             self._storage.load(ZERO, '')
         except KeyError:
-            from ZODB.Transaction import Transaction
+            from transaction import Transaction
             file = StringIO()
             p = cPickle.Pickler(file, 1)
             p.dump((PersistentMapping, None))


=== Zope3/src/ZODB/tests/MTStorage.py 1.15 => 1.16 ===
--- Zope3/src/ZODB/tests/MTStorage.py:1.15	Thu Feb 26 19:31:55 2004
+++ Zope3/src/ZODB/tests/MTStorage.py	Wed Mar 31 22:56:57 2004
@@ -3,13 +3,13 @@
 import threading
 import time
 
-import ZODB
 from persistent.mapping import PersistentMapping
+import transaction
 
+import ZODB
 from ZODB.tests.StorageTestBase \
      import zodb_pickle, zodb_unpickle, handle_serials
 from ZODB.tests.MinPO import MinPO
-from ZODB.Transaction import Transaction
 from ZODB.POSException import ConflictError
 
 SHORT_DELAY = 0.01
@@ -59,6 +59,7 @@
 
     def runtest(self):
         conn = self.db.open()
+        conn.sync()
         root = conn.root()
         d = self.get_thread_dict(root)
         if d is None:
@@ -126,7 +127,7 @@
 
     def dostore(self, i):
         data = zodb_pickle(MinPO((self.getName(), i)))
-        t = Transaction()
+        t = transaction.Transaction()
         oid = self.oid()
         self.pause()
 


=== Zope3/src/ZODB/tests/IteratorStorage.py 1.19 => 1.20 ===
--- Zope3/src/ZODB/tests/IteratorStorage.py:1.19	Tue Feb 17 20:12:59 2004
+++ Zope3/src/ZODB/tests/IteratorStorage.py	Wed Mar 31 22:56:57 2004
@@ -20,8 +20,8 @@
 from ZODB.tests.MinPO import MinPO
 from ZODB.tests.StorageTestBase import zodb_pickle, zodb_unpickle
 from ZODB.utils import U64, p64
-from ZODB.Transaction import Transaction
 
+from transaction import Transaction
 
 class IteratorCompare:
 


=== Zope3/src/ZODB/tests/HistoryStorage.py 1.14 => 1.15 ===
--- Zope3/src/ZODB/tests/HistoryStorage.py:1.14	Thu Feb 26 19:31:55 2004
+++ Zope3/src/ZODB/tests/HistoryStorage.py	Wed Mar 31 22:56:57 2004
@@ -17,8 +17,8 @@
 all these tests.
 """
 
-from ZODB.Transaction import Transaction
 from ZODB.tests.MinPO import MinPO
+from transaction import Transaction
 
 class HistoryStorage:
     def checkSimpleHistory(self):


=== Zope3/src/ZODB/tests/ConflictResolution.py 1.15 => 1.16 ===
--- Zope3/src/ZODB/tests/ConflictResolution.py:1.15	Thu Feb 26 19:31:55 2004
+++ Zope3/src/ZODB/tests/ConflictResolution.py	Wed Mar 31 22:56:57 2004
@@ -13,9 +13,9 @@
 ##############################################################################
 """Tests for application-level conflict resolution."""
 
-from ZODB.Transaction import Transaction
 from ZODB.POSException import ConflictError, UndoError
 from persistent import Persistent
+from transaction import Transaction
 
 from ZODB.tests.StorageTestBase import zodb_unpickle, zodb_pickle
 


=== Zope3/src/ZODB/tests/BasicStorage.py 1.28 => 1.29 ===
--- Zope3/src/ZODB/tests/BasicStorage.py:1.28	Wed Dec 24 11:01:58 2003
+++ Zope3/src/ZODB/tests/BasicStorage.py	Wed Mar 31 22:56:57 2004
@@ -19,20 +19,20 @@
 All storages should be able to pass these tests.
 """
 
-from ZODB.Transaction import Transaction
 from ZODB import POSException
-
 from ZODB.tests.MinPO import MinPO
 from ZODB.tests.StorageTestBase \
      import zodb_unpickle, zodb_pickle, handle_serials
 
+import transaction
+
 ZERO = '\0'*8
 
 
 
 class BasicStorage:
     def checkBasics(self):
-        t = Transaction()
+        t = transaction.Transaction()
         self._storage.tpc_begin(t)
         # This should simply return
         self._storage.tpc_begin(t)
@@ -44,10 +44,10 @@
         self.assertRaises(
             POSException.StorageTransactionError,
             self._storage.store,
-            0, 0, 0, 0, Transaction())
+            0, 0, 0, 0, transaction.Transaction())
 
         try:
-            self._storage.abortVersion('dummy', Transaction())
+            self._storage.abortVersion('dummy', transaction.Transaction())
         except (POSException.StorageTransactionError,
                 POSException.VersionCommitError):
             pass # test passed ;)
@@ -55,7 +55,7 @@
             assert 0, "Should have failed, invalid transaction."
 
         try:
-            self._storage.commitVersion('dummy', 'dummer', Transaction())
+            self._storage.commitVersion('dummy', 'dummer', transaction.Transaction())
         except (POSException.StorageTransactionError,
                 POSException.VersionCommitError):
             pass # test passed ;)
@@ -65,13 +65,13 @@
         self.assertRaises(
             POSException.StorageTransactionError,
             self._storage.store,
-            0, 1, 2, 3, Transaction())
+            0, 1, 2, 3, transaction.Transaction())
         self._storage.tpc_abort(t)
 
     def checkSerialIsNoneForInitialRevision(self):
         eq = self.assertEqual
         oid = self._storage.new_oid()
-        txn = Transaction()
+        txn = transaction.Transaction()
         self._storage.tpc_begin(txn)
         # Use None for serial.  Don't use _dostore() here because that coerces
         # serial=None to serial=ZERO.
@@ -120,7 +120,7 @@
 
     def checkWriteAfterAbort(self):
         oid = self._storage.new_oid()
-        t = Transaction()
+        t = transaction.Transaction()
         self._storage.tpc_begin(t)
         self._storage.store(oid, ZERO, zodb_pickle(MinPO(5)), '', t)
         # Now abort this transaction
@@ -133,7 +133,7 @@
         oid1 = self._storage.new_oid()
         revid1 = self._dostore(oid=oid1, data=MinPO(-2))
         oid = self._storage.new_oid()
-        t = Transaction()
+        t = transaction.Transaction()
         self._storage.tpc_begin(t)
         self._storage.store(oid, ZERO, zodb_pickle(MinPO(5)), '', t)
         # Now abort this transaction
@@ -176,7 +176,7 @@
 
     def checkTwoArgBegin(self):
         # XXX how standard is three-argument tpc_begin()?
-        t = Transaction()
+        t = transaction.Transaction()
         tid = '\0\0\0\0\0psu'
         self._storage.tpc_begin(t, tid)
         oid = self._storage.new_oid()
@@ -205,7 +205,7 @@
 
     def checkNote(self):
         oid = self._storage.new_oid()
-        t = Transaction()
+        t = transaction.Transaction()
         self._storage.tpc_begin(t)
         t.note('this is a test')
         self._storage.store(oid, ZERO, zodb_pickle(MinPO(5)), '', t)




More information about the Zodb-checkins mailing list