[Zope3-checkins] CVS: Zope3/src/zodb/zeo - client.py:1.16

Barry Warsaw barry@zope.com
Thu, 10 Jul 2003 13:45:04 -0400


Update of /cvs-repository/Zope3/src/zodb/zeo
In directory cvs.zope.org:/tmp/cvs-serv28002

Modified Files:
	client.py 
Log Message:
Better coverage for lastTransaction() by moving the most common usage
into the BaseStorage class.  Since this method is required by
IStorage, and most implementations do it the same way, it makes
sense.

__init__(): Initialize self._ltid to ZERO so it can pass
testLastTransactionBeforeFirstTransaction().

end_transaction(), tpcFinish(): Move the updating of self._ltid to the
latter method from the former so that we can more properly set it to a
transaction id, rather than a TimeStamp object.


=== Zope3/src/zodb/zeo/client.py 1.15 => 1.16 ===
--- Zope3/src/zodb/zeo/client.py:1.15	Thu Jun 26 14:02:24 2003
+++ Zope3/src/zodb/zeo/client.py	Thu Jul 10 13:44:59 2003
@@ -41,6 +41,7 @@
 from zodb.zeo.interfaces import *
 from zodb.storage.interfaces import *
 from zodb.timestamp import TimeStamp
+from zodb.interfaces import ZERO
 
 try:
     from zodb.conflict import ResolvedSerial
@@ -228,6 +229,11 @@
         self._tbuf = self.TransactionBufferClass()
         self._db = None
 
+        # Ironically, client storage is the one storage that doesn't really
+        # need lastTransaction, but it's defined in IStorage so might as well
+        # make it work.
+        self._ltid = ZERO
+
         # _serials: stores (oid, serialno) as returned by server
         # _seriald: _check_serials() moves from _serials to _seriald,
         #           which maps oid to serialno
@@ -842,7 +848,6 @@
         """Internal helper to end a transaction."""
         # the right way to set self._transaction to None
         # calls notify() on _tpc_cond in case there are waiting threads
-        self._ltid = self._serial
         self._tpc_cond.acquire()
         self._transaction = None
         self._tpc_cond.notify()
@@ -887,6 +892,7 @@
 
             tid = self._server.tpcFinish(self._serial)
             self._cache.setLastTid(tid)
+            self._ltid = tid
 
             r = self._check_serials()
             assert r is None or len(r) == 0, "unhandled serialnos: %s" % r