[Zope3-checkins] CVS: Zope3/src/ZODB - Transaction.py:1.58.2.1 TmpStore.py:1.11.26.1 Connection.py:1.140.2.1

Jeremy Hylton jeremy at zope.com
Thu Mar 18 16:18:36 EST 2004


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

Modified Files:
      Tag: jeremy-txn-branch
	Transaction.py TmpStore.py Connection.py 
Log Message:
Commit working changes for ReviseTransactionAPI to jeremy-txn-branch.

All of the transaction tests pass except for two failures 
    testExceptionInSubAbortSub
    testExceptionInSubCommitSub


=== Zope3/src/ZODB/Transaction.py 1.58 => 1.58.2.1 ===
--- Zope3/src/ZODB/Transaction.py:1.58	Thu Feb 26 19:31:53 2004
+++ Zope3/src/ZODB/Transaction.py	Thu Mar 18 16:18:34 2004
@@ -532,25 +532,27 @@
 ############################################################################
 # install get_transaction:
 
-# Map thread ident to its Transaction instance.
-_tid2tran = {}
+### Map thread ident to its Transaction instance.
+##_tid2tran = {}
 
-# Get Transaction associated with current thread; if none, create a
-# new Transaction and return it.
-def get_transaction():
-    tid = _get_ident()
-    result = _tid2tran.get(tid)
-    if result is None:
-        _tid2tran[tid] = result = Transaction(tid)
-    return result
+### Get Transaction associated with current thread; if none, create a
+### new Transaction and return it.
+##def get_transaction():
+##    tid = _get_ident()
+##    result = _tid2tran.get(tid)
+##    if result is None:
+##        _tid2tran[tid] = result = Transaction(tid)
+##    return result
 
-# Forget whatever Transaction (if any) is associated with current thread.
-def free_transaction():
-    tid = _get_ident()
-    try:
-        del _tid2tran[tid]
-    except KeyError:
-        pass
+### Forget whatever Transaction (if any) is associated with current thread.
+##def free_transaction():
+##    tid = _get_ident()
+##    try:
+##        del _tid2tran[tid]
+##    except KeyError:
+##        pass
+
+from transaction import get as get_transaction
 
 import __builtin__
 __builtin__.get_transaction = get_transaction


=== Zope3/src/ZODB/TmpStore.py 1.11 => 1.11.26.1 ===
--- Zope3/src/ZODB/TmpStore.py:1.11	Thu Oct  2 14:17:19 2003
+++ Zope3/src/ZODB/TmpStore.py	Thu Mar 18 16:18:34 2004
@@ -22,8 +22,9 @@
 
     _bver = ''
 
-    def __init__(self, base_version):
+    def __init__(self, base_version, storage):
         self._transaction = None
+        self._storage = storage
         if base_version:
             self._bver = base_version
         self._file = tempfile.TemporaryFile()
@@ -34,14 +35,13 @@
         self._index = {}
         # _tindex: map oid to pos for new updates
         self._tindex = {}
-        self._db = None
         self._creating = []
 
     def close(self):
         self._file.close()
 
     def getName(self):
-        return self._db.getName()
+        return self._storage.getName()
 
     def getSize(self):
         return self._pos
@@ -66,14 +66,13 @@
     def modifiedInVersion(self, oid):
         if self._index.has_key(oid):
             return self._bver
-        return self._db._storage.modifiedInVersion(oid)
+        return self._storage.modifiedInVersion(oid)
 
     def new_oid(self):
-        return self._db._storage.new_oid()
+        return self._storage.new_oid()
 
     def registerDB(self, db, limit):
-        self._db = db
-        self._storage = db._storage
+        pass
 
     def store(self, oid, serial, data, version, transaction):
         if transaction is not self._transaction:


=== Zope3/src/ZODB/Connection.py 1.140 => 1.140.2.1 ===
--- Zope3/src/ZODB/Connection.py:1.140	Tue Mar 16 11:18:20 2004
+++ Zope3/src/ZODB/Connection.py	Thu Mar 18 16:18:34 2004
@@ -26,6 +26,8 @@
 from persistent import PickleCache
 from persistent.interfaces import IPersistent
 
+import transaction
+
 from ZODB.ConflictResolution import ResolvedSerial
 from ZODB.ExportImport import ExportImport
 from ZODB.POSException \
@@ -190,7 +192,7 @@
         t = self._transaction
         if t is None:
             # Fall back to thread-bound transactions
-            t = get_transaction()
+            t = transaction.get()
         return t
 
     def setLocalTransaction(self):
@@ -829,19 +831,16 @@
             del obj._p_oid
             del obj._p_jar
 
-    def tpc_begin(self, transaction, sub=None):
+    def tpc_begin(self, transaction, sub=False):
         self._modified = []
         
         # _creating is a list of oids of new objects, which is used to
         # remove them from the cache if a transaction aborts.
         self._creating = []
-        if sub:
+        if sub and self._tmp is None:
             # Sub-transaction!
-            if self._tmp is None:
-                _tmp = TmpStore(self._version)
-                self._tmp = self._storage
-                self._storage = _tmp
-                _tmp.registerDB(self._db, 0)
+            self._tmp = self._storage
+            self._storage = TmpStore(self._version, self._storage)
 
         self._storage.tpc_begin(transaction)
 




More information about the Zope3-Checkins mailing list