[Zodb-checkins] CVS: Zope3/src/zodb/storage - file.py:1.8.4.12

Jeremy Hylton jeremy@zope.com
Wed, 12 Mar 2003 12:52:57 -0500


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

Modified Files:
      Tag: opaque-pickles-branch
	file.py 
Log Message:
Improve readability of commitVersion implementation.


=== Zope3/src/zodb/storage/file.py 1.8.4.11 => 1.8.4.12 ===
--- Zope3/src/zodb/storage/file.py:1.8.4.11	Wed Mar 12 12:33:11 2003
+++ Zope3/src/zodb/storage/file.py	Wed Mar 12 12:52:54 2003
@@ -683,7 +683,7 @@
     def abortVersion(self, src, transaction):
         return self.commitVersion(src, '', transaction, abort=True)
 
-    def commitVersion(self, src, dest, transaction, abort=None):
+    def commitVersion(self, src, dest, transaction, abort=False):
         # We are going to commit by simply storing back pointers.
         if self._is_read_only:
             raise ReadOnlyError()
@@ -708,7 +708,7 @@
         finally:
             self._lock_release()
 
-    def _commitVersion(self, src, dest, transaction, abort=None):
+    def _commitVersion(self, src, dest, transaction, abort=False):
         # call after checking arguments and acquiring lock
         srcpos = self._vindex.get(src, 0)
         spos = p64(srcpos)
@@ -718,20 +718,23 @@
         #    always 0
         middle = struct.pack(">QHIQ", self._pos, len(dest), 0, 0)
 
-        # Argh!  what does heredelta mean?
+        # recsize is the total size of a data record written by
+        # commit version.  The var here stores the location of the
+        # current data record.  here is incremented by recsize
+        # each time we write an object record.
+
+        # Add 8 to header size to account for backpointer.
         if dest:
             sd = p64(self._vindex.get(dest, 0))
-            heredelta = 66 + len(dest)
+            recsize = DATA_VERSION_HDR_LEN + 8 + len(dest)
         else:
             sd = ''
-            heredelta = 54
+            recsize = DATA_HDR_LEN + 8
 
         here = self._pos + self._tfile.tell() + self._thl
         oids = []
         current_oids = {}
-        t = None
-        tstatus = ' '
-        if abort is None:
+        if not abort:
             newserial = self._serial
 
         while srcpos:
@@ -758,10 +761,11 @@
 
                 self._tfile.write(abort and p64(h.pnv) or spos)
                 # data backpointer to src data
-                here += heredelta
+                here += recsize
 
                 current_oids[h.oid] = 1
             else:
+                # XXX I don't understand this branch.  --jeremy
                 # Hm.  This is a non-current record.  Is there a
                 # current record for this oid?
                 if not current_oids.has_key(h.oid):