[Zodb-checkins] CVS: ZODB3/ZODB/FileStorage - FileStorage.py:1.1.2.4
    Jeremy Hylton 
    cvs-admin at zope.org
       
    Wed Nov  5 23:34:16 EST 2003
    
    
  
Update of /cvs-repository/ZODB3/ZODB/FileStorage
In directory cvs.zope.org:/tmp/cvs-serv28251/ZODB/FileStorage
Modified Files:
      Tag: ZODB3-mvcc-2-branch
	FileStorage.py 
Log Message:
Add loadEx() call that returns data, serial, and tid.
Th new ZEO cache is going to need the tid associated with an object in
addition to its serial number, since it can't guarantee that they are
the same.
The new tests fail for storages other that File and Mapping, because I
haven't implemented loadEx() for them.
=== ZODB3/ZODB/FileStorage/FileStorage.py 1.1.2.3 => 1.1.2.4 ===
--- ZODB3/ZODB/FileStorage/FileStorage.py:1.1.2.3	Thu Oct 30 15:38:01 2003
+++ ZODB3/ZODB/FileStorage/FileStorage.py	Wed Nov  5 23:33:44 2003
@@ -535,6 +535,28 @@
         except TypeError:
             raise TypeError("invalid oid %r" % (oid,))
 
+    def loadEx(self, oid, version):
+        # A variant of load() that also returns a transaction id.
+        # ZEO wants this for managing its cache.
+        self._lock_acquire()
+        try:
+            pos = self._lookup_pos(oid)
+            h = self._read_data_header(pos, oid)
+            if h.version and h.version != version:
+                data, serial, _, tloc = self._loadBack_impl(oid, h.pnv)
+                th = self._read_txn_header(tloc)
+                return data, serial, th.tid
+            if h.plen:
+                th = self._read_txn_header(h.tloc)
+                return self._file.read(h.plen), h.serial, th.tid
+            else:
+                data, _, _, tloc = self._loadBack_impl(oid, h.back)
+                th = self._read_txn_header(h.tloc)
+                return data, h.serial, th.tid
+            raise RuntimeError
+        finally:
+            self._lock_release()
+
     def load(self, oid, version):
         self._lock_acquire()
         try:
@@ -568,6 +590,9 @@
                 return _loadBack(self._file, oid, h.back)[0]
         finally:
             self._lock_release()
+
+    def loadNonCurrent(self, oid, tid):
+        pass
 
     def modifiedInVersion(self, oid):
         self._lock_acquire()
    
    
More information about the Zodb-checkins
mailing list