[Zodb-checkins] CVS: Zope3/src/ZODB - DB.py:1.71.2.3

Jeremy Hylton jeremy at zope.com
Tue Mar 30 14:43:52 EST 2004


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

Modified Files:
      Tag: jeremy-txn-branch
	DB.py 
Log Message:
Use the transaction package explicitly.


=== Zope3/src/ZODB/DB.py 1.71.2.2 => 1.71.2.3 ===
--- Zope3/src/ZODB/DB.py:1.71.2.2	Tue Mar 23 15:48:38 2004
+++ Zope3/src/ZODB/DB.py	Tue Mar 30 14:43:50 2004
@@ -23,9 +23,10 @@
 from ZODB.broken import find_global
 from ZODB.Connection import Connection
 from ZODB.serialize import referencesf
-from ZODB.Transaction import Transaction, get_transaction
 from zLOG import LOG, ERROR
 
+import transaction
+
 class DB(object):
     """The Object Database
     -------------------
@@ -132,7 +133,7 @@
             p = cPickle.Pickler(file, 1)
             p.dump((root.__class__, None))
             p.dump(root.__getstate__())
-            t = Transaction()
+            t = transaction.Transaction()
             t.description = 'initial database creation'
             storage.tpc_begin(t)
             storage.store('\0\0\0\0\0\0\0\0', None, file.getvalue(), '', t)
@@ -140,13 +141,12 @@
             storage.tpc_finish(t)
 
         # Pass through methods:
-        for m in ('history',
-                  'supportsUndo', 'supportsVersions', 'undoLog',
-                  'versionEmpty', 'versions'):
+        for m in ['history', 'supportsUndo', 'supportsVersions', 'undoLog',
+                  'versionEmpty', 'versions']:
             setattr(self, m, getattr(storage, m))
 
         if hasattr(storage, 'undoInfo'):
-            self.undoInfo=storage.undoInfo
+            self.undoInfo = storage.undoInfo
 
 
     def _cacheMean(self, attr):
@@ -206,10 +206,10 @@
                 self._temps=t
         finally: self._r()
 
-    def abortVersion(self, version, transaction=None):
-        if transaction is None:
-            transaction = get_transaction()
-        transaction.register(AbortVersion(self, version))
+    def abortVersion(self, version, txn=None):
+        if txn is None:
+            txn = transaction.get()
+        txn.register(AbortVersion(self, version))
 
     def cacheDetail(self):
         """Return information on objects in the various caches
@@ -316,10 +316,10 @@
         """
         self._storage.close()
 
-    def commitVersion(self, source, destination='', transaction=None):
-        if transaction is None:
-            transaction = get_transaction()
-        transaction.register(CommitVersion(self, source, destination))
+    def commitVersion(self, source, destination='', txn=None):
+        if txn is None:
+            txn = transaction.get()
+        txn.register(CommitVersion(self, source, destination))
 
     def getCacheSize(self):
         return self._cache_size
@@ -611,7 +611,7 @@
 
     def cacheStatistics(self): return () # :(
 
-    def undo(self, id, transaction=None):
+    def undo(self, id, txn=None):
         """Undo a transaction identified by id.
 
         A transaction can be undone if all of the objects involved in
@@ -625,12 +625,12 @@
 
         :Parameters:
           - `id`: a storage-specific transaction identifier
-          - `transaction`: transaction context to use for undo().
+          - `txn`: transaction context to use for undo().
             By default, uses the current transaction.
         """
-        if transaction is None:
-            transaction = get_transaction()
-        transaction.register(TransactionalUndo(self, id))
+        if txn is None:
+            txn = transaction.get()
+        txn.register(TransactionalUndo(self, id))
 
     def versionEmpty(self, version):
         return self._storage.versionEmpty(version)




More information about the Zodb-checkins mailing list