[Zope-Checkins] CVS: StandaloneZODB/ZODB - FileStorage.py:1.77.4.7

Barry Warsaw barry@wooz.org
Thu, 24 Jan 2002 17:25:10 -0500


Update of /cvs-repository/StandaloneZODB/ZODB
In directory cvs.zope.org:/tmp/cvs-serv25273

Modified Files:
      Tag: Recovery
	FileStorage.py 
Log Message:
recover(): We need to handle George Bailey objects, those who's
creation has been undone.  In that case, data will be None, so don't
try to take its length. :)

Also, don't attempt to write the data if it's None.


=== StandaloneZODB/ZODB/FileStorage.py 1.77.4.6 => 1.77.4.7 ===
         #
         # - Nothing is returned
+        #
+        # - data can be None, which indicates a George Bailey object (i.e. one
+        #   who's creation has been transactionally undone).
         if self._is_read_only:
             raise POSException.ReadOnlyError()
         if transaction is not self._transaction:
@@ -723,9 +726,13 @@
             # And update the temp file index
             self._tindex[oid] = here
             # Write the recovery data record
+            if data is None:
+                dlen = 0
+            else:
+                dlen = len(data)
             self._tfile.write(pack('>8s8s8s8sH8s',
-                              oid, serial, p64(old), p64(self._pos),
-                              len(version), p64(len(data))))
+                                   oid, serial, p64(old), p64(self._pos),
+                                   len(version), p64(dlen)))
             # We need to write some version information if this revision is
             # happening in a version.
             if version:
@@ -744,7 +751,8 @@
                 self._tvindex[version] = here
                 self._tfile.write(version)
             # And finally, write the data
-            self._tfile.write(data)
+            if data is not None:
+                self._tfile.write(data)
         finally:
             self._lock_release()