[Zodb-checkins] CVS: ZODB3/ZODB/FileStorage - FileStorage.py:1.1.2.17

Jeremy Hylton cvs-admin at zope.org
Tue Nov 25 12:00:31 EST 2003


Update of /cvs-repository/ZODB3/ZODB/FileStorage
In directory cvs.zope.org:/tmp/cvs-serv14269

Modified Files:
      Tag: ZODB3-mvcc-2-branch
	FileStorage.py 
Log Message:
cleanup stuff

Remove _loadBack related functions defined in this module.  All
callers should be using the _loadBack methods defined in the format
module.

Pretty up _truncate() a little.  Extend error() so that we can log the
actual exception that causes truncate to fail.


=== ZODB3/ZODB/FileStorage/FileStorage.py 1.1.2.16 => 1.1.2.17 ===
--- ZODB3/ZODB/FileStorage/FileStorage.py:1.1.2.16	Tue Nov 25 00:44:07 2003
+++ ZODB3/ZODB/FileStorage/FileStorage.py	Tue Nov 25 12:00:30 2003
@@ -61,9 +61,9 @@
     LOG('ZODB FS', WARNING, "%s  warn: %s\n" % (packed_version,
                                                 message % data))
 
-def error(message, *data):
+def error(message, *data, **kwargs):
     LOG('ZODB FS', ERROR, "%s ERROR: %s\n" % (packed_version,
-                                              message % data))
+                                              message % data), **kwargs)
 
 def nearPanic(message, *data):
     LOG('ZODB FS', PANIC, "%s ERROR: %s\n" % (packed_version,
@@ -1737,75 +1737,29 @@
     return pos, maxoid, ltid
 
 
-def _loadBack_impl(file, oid, back):
-    # shared implementation used by various _loadBack methods
-    while 1:
-        old = u64(back)
-        if not old:
-            # If the backpointer is 0, the object does not currently exist.
-            raise POSKeyError(oid)
-        file.seek(old)
-        h = file.read(DATA_HDR_LEN)
-        doid, serial, prev, tloc, vlen, plen = unpack(DATA_HDR, h)
-
-        if vlen:
-            file.read(16 + vlen)
-        if plen != z64:
-            return file.read(u64(plen)), serial, old, tloc
-        back = file.read(8) # We got a back pointer!
-
-def _loadBack(file, oid, back):
-    data, serial, old, tloc = _loadBack_impl(file, oid, back)
-    return data, serial
-
-def _loadBackPOS(file, oid, back):
-    """Return position of data record for backpointer."""
-    data, serial, old, tloc = _loadBack_impl(file, oid, back)
-    return old
-
-def _loadBackTxn(file, oid, back):
-    """Return data, serial, and txn id for backpointer."""
-    data, serial, old, stloc = _loadBack_impl(file, oid, back)
-    tloc = u64(stloc)
-    file.seek(tloc)
-    h = file.read(TRANS_HDR_LEN)
-    tid = h[:8]
-    return data, serial, tid
-
-def getTxnFromData(file, oid, back):
-    """Return transaction id for data at back."""
-    file.seek(u64(back))
-    h = file.read(DATA_HDR_LEN)
-    doid, serial, prev, stloc, vlen, plen = unpack(DATA_HDR, h)
-    assert oid == doid
-    tloc = u64(stloc)
-    file.seek(tloc)
-    # seek to transaction header, where tid is first 8 bytes
-    return file.read(8)
-
 def _truncate(file, name, pos):
-    seek=file.seek
-    seek(0,2)
-    file_size=file.tell()
+    file.seek(0, 2)
+    file_size = file.tell()
     try:
-        i=0
+        i = 0
         while 1:
             oname='%s.tr%s' % (name, i)
             if os.path.exists(oname):
-                i=i+1
+                i += 1
             else:
                 warn("Writing truncated data from %s to %s", name, oname)
-                o=open(oname,'wb')
-                seek(pos)
+                o = open(oname,'wb')
+                file.seek(pos)
                 cp(file, o, file_size-pos)
                 o.close()
                 break
     except:
-        error("couldn\'t write truncated data for %s", name)
+        error("couldn\'t write truncated data for %s", name,
+              error=sys.exc_info())
         raise POSException.StorageSystemError, (
             "Couldn't save truncated data")
 
-    seek(pos)
+    file.seek(pos)
     file.truncate()
 
 class Iterator:
@@ -2025,6 +1979,8 @@
                     data = None
                 else:
                     data, _s, tid = self._loadBackTxn(h.oid, h.back, False)
+                    # XXX looks like this only goes one link back, should
+                    # it go to the original data like BDBFullStorage?
                     prev_txn = self.getTxnFromData(h.oid, h.back)
 
             r = Record(h.oid, h.serial, h.version, data, prev_txn)




More information about the Zodb-checkins mailing list