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

Jeremy Hylton jeremy at zope.com
Fri Apr 18 13:13:14 EDT 2003


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

Modified Files:
      Tag: jeremy-new-pack-branch
	format.py 
Log Message:
Add an optional to _loadBack_impl to provide data even for 0 backpointer.

Useful for packing George Bailey.


=== Zope3/src/zodb/storage/file/format.py 1.1.2.2 => 1.1.2.3 ===
--- Zope3/src/zodb/storage/file/format.py:1.1.2.2	Wed Apr 16 14:20:52 2003
+++ Zope3/src/zodb/storage/file/format.py	Fri Apr 18 12:13:13 2003
@@ -395,8 +395,13 @@
         h.ext = self._file.read(h.elen)
         return h
 
-    def _loadBack_impl(self, oid, back):
+    def _loadBack_impl(self, oid, back, fail):
         # shared implementation used by various _loadBack methods
+        #
+        # If the backpointer ultimately resolves to 0:
+        # If fail is True, raise KeyError for zero backpointer.
+        # If fail is False, return the empty data from the record
+        # with no backpointer.
         while 1:
             if not back:
                 # If backpointer is 0, object does not currently exist.
@@ -405,20 +410,23 @@
             refs = self._file.read(h.nrefs * 8)
             if h.plen:
                 return self._file.read(h.plen), refs, h.serial, back, h.tloc
+            if h.back == 0 and not fail:
+                assert h.nrefs == 0
+                return None, None, h.serial, back, h.tloc
             back = h.back
 
-    def _loadBack(self, oid, back):
-        data, refs, serial, old, tloc = self._loadBack_impl(oid, back)
+    def _loadBack(self, oid, back, fail=True):
+        data, refs, serial, old, tloc = self._loadBack_impl(oid, back, fail)
         return data, serial
 
-    def _loadBackPOS(self, oid, back):
+    def _loadBackPOS(self, oid, back, fail=True):
         """Return position of data record for backpointer."""
-        data, refs, serial, old, tloc = self._loadBack_impl(oid, back)
+        data, refs, serial, old, tloc = self._loadBack_impl(oid, back, fail)
         return old
 
-    def _loadBackTxn(self, oid, back):
+    def _loadBackTxn(self, oid, back, fail=True):
         """Return data, serial, and txn id for backpointer."""
-        data, refs, serial, old, tloc = self._loadBack_impl(oid, back)
+        data, refs, serial, old, tloc = self._loadBack_impl(oid, back, fail)
         self._file.seek(tloc)
         h = self._file.read(TRANS_HDR_LEN)
         tid = h[:8]




More information about the Zodb-checkins mailing list