[Zodb-checkins] SVN: ZODB/branches/3.4/src/Z load() and loadEx(): eliminate gratuitous differences.

Tim Peters tim.one at comcast.net
Tue Jul 5 15:21:07 EDT 2005


Log message for revision 31012:
  load() and loadEx():  eliminate gratuitous differences.
  
  Ideally, load() should call loadEx() instead, but we really
  don't want "an extra" Python-level call here (heavily used).
  
  loadEx():  deleted pointless call of self._read_txn_header().
  
  ServerStub.loadEx() comments:  these were obviously wrong in
  several ways, but I don't know the full truth.  Better to
  say so up front than to leave them clearly wrong, though.
  

Changed:
  U   ZODB/branches/3.4/src/ZEO/ServerStub.py
  U   ZODB/branches/3.4/src/ZODB/FileStorage/FileStorage.py

-=-
Modified: ZODB/branches/3.4/src/ZEO/ServerStub.py
===================================================================
--- ZODB/branches/3.4/src/ZEO/ServerStub.py	2005-07-05 17:47:40 UTC (rev 31011)
+++ ZODB/branches/3.4/src/ZEO/ServerStub.py	2005-07-05 19:21:06 UTC (rev 31012)
@@ -173,12 +173,17 @@
         return self.rpc.call('zeoLoad', oid)
 
     ##
-    # Return current data for oid along with tid if transaction that
-    # wrote the date.
+    # Return current data for oid in version, the tid of the transaction that
+    # wrote the most recent revision, and the name of the version for the
+    # data returned.  Versions make this hard to understand; in particular,
+    # the version string returned may not equal the version string passed
+    # in, and that's "a feature" I don't understand.  Similarly, the tid
+    # returned is the tid of the most recent revision of oid, and that may
+    # not equal the tid of the transaction that wrote the data returned.
     # @param oid object id
     # @param version string, name of version
-    # @defreturn 4-tuple
-    # @return data, serial number, transaction id, version,
+    # @defreturn 3-tuple
+    # @return data, transaction id, version
     #         where version is the name of the version the data came
     #         from or "" for non-version data
     # @exception KeyError if oid is not found

Modified: ZODB/branches/3.4/src/ZODB/FileStorage/FileStorage.py
===================================================================
--- ZODB/branches/3.4/src/ZODB/FileStorage/FileStorage.py	2005-07-05 17:47:40 UTC (rev 31011)
+++ ZODB/branches/3.4/src/ZODB/FileStorage/FileStorage.py	2005-07-05 19:21:06 UTC (rev 31012)
@@ -516,7 +516,7 @@
             raise TypeError("invalid oid %r" % (oid,))
 
     def loadEx(self, oid, version):
-        # A variant of load() that also returns a transaction id.
+        # A variant of load() that also returns the version string.
         # ZEO wants this for managing its cache.
         self._lock_acquire()
         try:
@@ -524,7 +524,6 @@
             h = self._read_data_header(pos, oid)
             if h.version and h.version != version:
                 # Return data and tid from pnv (non-version data).
-
                 # If we return the old record's transaction id, then
                 # it will look to the cache like old data is current.
                 # The tid for the current data must always be greater
@@ -537,8 +536,7 @@
             else:
                 # Get the data from the backpointer, but tid from
                 # currnt txn.
-                data, _, _, _ = self._loadBack_impl(oid, h.back)
-                th = self._read_txn_header(h.tloc)
+                data = self._loadBack_impl(oid, h.back)[0]
                 return data, h.tid, h.version
         finally:
             self._lock_release()
@@ -553,8 +551,11 @@
                 data = self._loadBack_impl(oid, h.pnv)[0]
                 return data, h.tid
             if h.plen:
-                return self._file.read(h.plen), h.tid
+                data = self._file.read(h.plen)
+                return data, h.tid
             else:
+                # Get the data from the backpointer, but tid from
+                # currnt txn.
                 data = self._loadBack_impl(oid, h.back)[0]
                 return data, h.tid
         finally:



More information about the Zodb-checkins mailing list