[Zodb-checkins] CVS: Zope3/src/zodb/storage - base.py:1.31

Barry Warsaw barry at zope.com
Thu Jul 10 14:35:25 EDT 2003


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

Modified Files:
	base.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.

BaseStorage.__init__(): Initialize self._ltid to ZERO.

BaseStorage.lastTransaction(): Simply return self._ltid

BerkeleyBase._finish(): Refactor common implementations from derived
classes.  This now sets self._ltid to the tid argument so
BDBMinimalStorage now gets its lastTransaction() implementation for
free.

BerkeleyBase._abort(): Base classes must implement this


=== Zope3/src/zodb/storage/base.py 1.30 => 1.31 ===
--- Zope3/src/zodb/storage/base.py:1.30	Thu Jun 19 17:41:10 2003
+++ Zope3/src/zodb/storage/base.py	Thu Jul 10 13:35:18 2003
@@ -121,6 +121,14 @@
         self._ts = newTimeStamp()
         self._serial = self._ts.raw()
         self._oid = ZERO
+        self._ltid = ZERO
+
+    def lastTransaction(self):
+        """Return transaction id for last committed transaction.
+
+        If no transactions have yet been committed, return ZERO.
+        """
+        return self._ltid
 
     def abortVersion(self, src, transaction):
         if transaction is not self._transaction:
@@ -662,23 +670,15 @@
         pass
 
     def _finish(self, tid):
-        """Called from BaseStorage.tpc_finish(), this commits the underlying
-        BerkeleyDB transaction.
-        """
-        self._transaction.commit()
+        self._withtxn(self._docommit, self._serial)
+        self._ltid = tid
 
     def _abort(self):
-        """Called from BaseStorage.tpc_abort(), this aborts the underlying
-        BSDDB transaction.
-        """
-        self._transaction.abort()
+        raise NotImplementedError
 
     def _clear_temp(self):
-        """Called from BaseStorage.tpc_abort(), BaseStorage.tpc_begin(),
-        BaseStorage.tpc_finish(), this clears out the temporary log file
-        """
-        # BAW: no-op this since the right CommitLog file operations are
-        # performed by the methods in the derived storage class.
+        # This method is called from BaseStorage's tpcBegin(), tpcAbort() and
+        # tpcFinish(), but the Berkeley storages don't have a temp file.
         pass
 
     def _setVersion(self, txn, vstr):




More information about the Zodb-checkins mailing list