[Zodb-checkins] CVS: Packages/bsddb3Storage - CommitLog.py:1.5

barry@digicool.com barry@digicool.com
Fri, 13 Apr 2001 15:04:25 -0400 (EDT)


Update of /cvs-repository/Packages/bsddb3Storage
In directory korak:/tmp/cvs-serv14957

Modified Files:
	CommitLog.py 
Log Message:
write_object_undo(): Use this method instead of write_moved_object()
to record an undo transaction for an object.  This will remember the
previous revids for the undone objects, which is necessary because a
transaction may undo several revisions of an object.

get_prevrevid(): Given an oid, get the recorded previous revid for the
object.



--- Updated File CommitLog.py in package Packages/bsddb3Storage --
--- CommitLog.py	2001/04/04 19:23:34	1.4
+++ CommitLog.py	2001/04/13 19:04:24	1.5
@@ -328,10 +328,12 @@
         """Initialize the `full' commit log, usually with a new file."""
         CommitLog.__init__(self, file, dir)
         self.__versions = {}
+        self.__prevrevids = {}
 
     def finish(self):
         CommitLog.finish(self)
         self.__versions.clear()
+        self.__prevrevids.clear()
 
     def get_vid(self, version, missing=None):
         """Given a version string, return the associated vid.
@@ -339,6 +341,17 @@
         """
         return self.__versions.get(version, missing)
 
+    def get_prevrevid(self, oid, missing=None):
+        """Given an object id, return the associated prevrevid.
+        If not present, return `missing'.
+
+        This method serves to allow transactionalUndo() to find undone
+        transactions that have been committed to the log, but not to the
+        database (i.e. multiple transactionalUndo()'s during a single
+        transaction).
+        """
+        return self.__prevrevids.get(oid, missing)
+
     # read/write protocol
 
     def write_object(self, oid, vid, nvrevid, pickle, prevrevid):
@@ -356,6 +369,13 @@
         # Write an empty pickle since we're just moving the object and we'll
         # reuse the pickle already in the database.
         self._append('o', (oid, vid, nvrevid, lrevid, '', prevrevid))
+
+    def write_object_undo(self, oid, vid, nvrevid, lrevid, prevrevid):
+        # Identical to write_moved_object() except that we have to keep some
+        # extra info around.  Specifically, it's possible to undo multiple
+        # transactions in the same transaction.
+        self._append('o', (oid, vid, nvrevid, lrevid, '', prevrevid))
+        self.__prevrevids[oid] = prevrevid
 
     def write_new_version(self, version, vid):
         self._append('v', (version, vid))