[Zope3-checkins] CVS: Zope3/src/zodb/storage - bdbfull.py:1.16

Barry Warsaw barry@wooz.org
Fri, 14 Mar 2003 11:30:56 -0500


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

Modified Files:
	bdbfull.py 
Log Message:
Update some comments


=== Zope3/src/zodb/storage/bdbfull.py 1.15 => 1.16 ===
--- Zope3/src/zodb/storage/bdbfull.py:1.15	Thu Mar 13 18:32:30 2003
+++ Zope3/src/zodb/storage/bdbfull.py	Fri Mar 14 11:30:55 2003
@@ -1097,9 +1097,8 @@
                 return oid, vid+nvrevid+DNE+ctid, None, None
             # BAW: If the serial number of this object record is the same as
             # the serial we're being asked to undo, then I think we have a
-            # problem (since the storage invariant is that it doesn't retain
-            # metadata records for multiple modifications of the object in the
-            # same transaction).
+            # problem (since the storage invariant is that it retains only one
+            # metadata record per object revision).
             assert mrec[0][8:] <> ctid, 'storage invariant violated'
             # All is good, so just restore this metadata record
             return oid, mrec[1], None, None
@@ -1124,7 +1123,7 @@
             vid, nvrevid = unpack('>8s8s', self._metadata[oid+tid][:16])
             return oid, vid+nvrevid+DNE+ctid, None, None
         elif target_prevrevid == ZERO or last_prevrevid == ZERO:
-            # The object's revision is in it's initial creation state but
+            # The object's revision is in its initial creation state but
             # we're asking for an undo of something other than the initial
             # creation state.  No, no.
             raise UndoError, 'Undoing mismatched zombification'
@@ -1133,11 +1132,14 @@
         target_lrevid   = target_metadata[16:24]
         # If the pickle pointers of the object's last revision and the
         # undo-target revision are the same, then the transaction can be
-        # undone.  Note that we take a short cut here, since we really want to
-        # test pickle equality, but this is good enough for now.
+        # undone.  Note that we cannot test for pickle equality here because
+        # that would allow us to undo to an arbitrary object history.  Imagine
+        # a boolean object -- if undo tested for equality and not identity,
+        # then half the time we could undo to an arbitrary point in the
+        # object's history.
         if target_lrevid == last_lrevid:
             return oid, target_metadata, None, None
-        # Check previous transactionalUndos done in this transaction
+        # Check previous undos done in this transaction
         elif target_lrevid == self._prevrevids.get(oid):
             return oid, target_metadata, None, None
         else:
@@ -1201,10 +1203,10 @@
                 # data and refs go hand in hand
                 assert refs is None
             # We need to write all the new records for an object changing in
-            # this transaction.  Note that we only write to th serials table
+            # this transaction.  Note that we only write to the serials table
             # if prevrevids hasn't already seen this object, otherwise we'll
             # end up with multiple entries in the serials table for the same
-            # tid.
+            # object revision.
             if not self._prevrevids.has_key(oid):
                 self._serials.put(oid, newserial, txn=txn)
             self._metadata.put(revid, metadata, txn=txn)
@@ -1215,7 +1217,7 @@
                 if vid <> ZERO:
                     self._currentVersions.put(oid, vid, txn=txn)
             self._oids.put(oid, PRESENT, txn=txn)
-            rtnoids[oid] = 1
+            rtnoids[oid] = True
             # Add this object revision to the autopack table
             self._objrevs.put(newserial+oid, prevrevid, txn=txn)
         return rtnoids.keys()