[Neo-report] r2712 jm - in /trunk/neo/client: Storage.py app.py iterator.py

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Apr 12 18:16:06 CEST 2011


Author: jm
Date: Tue Apr 12 18:16:06 2011
New Revision: 2712

Log:
client: remove duplicate 'snapshot_tid' parameter of Application.load

Modified:
    trunk/neo/client/Storage.py
    trunk/neo/client/app.py
    trunk/neo/client/iterator.py

Modified: trunk/neo/client/Storage.py
==============================================================================
--- trunk/neo/client/Storage.py [iso-8859-1] (original)
+++ trunk/neo/client/Storage.py [iso-8859-1] Tue Apr 12 18:16:06 2011
@@ -119,16 +119,13 @@ class Storage(BaseStorage.BaseStorage,
             self._snapshot_tid = tid
         return tid
 
-    def _load(self, *args, **kw):
-        return self.app.load(self._getSnapshotTID(), *args, **kw)
-
     def load(self, oid, version=''):
         # XXX: interface definition states that version parameter is
         # mandatory, while some ZODB tests do not provide it. For now, make
         # it optional.
         assert version == '', 'Versions are not supported'
         try:
-            return self._load(oid)[:2]
+            return self.app.load(oid, None, self._getSnapshotTID())[:2]
         except NEOStorageNotFoundError:
             raise POSException.POSKeyError(oid)
 
@@ -174,13 +171,13 @@ class Storage(BaseStorage.BaseStorage,
     # mutliple revisions
     def loadSerial(self, oid, serial):
         try:
-            return self._load(oid, serial=serial)[0]
+            return self.app.load(oid, serial)[0]
         except NEOStorageNotFoundError:
             raise POSException.POSKeyError(oid)
 
     def loadBefore(self, oid, tid):
         try:
-            return self._load(oid, tid=tid)
+            return self.app.load(oid, None, tid)
         except NEOStorageDoesNotExistError:
             raise POSException.POSKeyError(oid)
         except NEOStorageNotFoundError:
@@ -222,7 +219,7 @@ class Storage(BaseStorage.BaseStorage,
 
     def loadEx(self, oid, version):
         try:
-            data, serial, _ = self._load(oid)
+            data, serial, _ = self.app.load(oid, None, self._getSnapshotTID())
         except NEOStorageNotFoundError:
             raise POSException.POSKeyError(oid)
         return data, serial, ''

Modified: trunk/neo/client/app.py
==============================================================================
--- trunk/neo/client/app.py [iso-8859-1] (original)
+++ trunk/neo/client/app.py [iso-8859-1] Tue Apr 12 18:16:06 2011
@@ -382,19 +382,16 @@ class Application(object):
         return int(u64(self.last_oid))
 
     @profiler_decorator
-    def load(self, snapshot_tid, oid, serial=None, tid=None):
+    def load(self, oid, tid=None, before_tid=None):
         """
         Internal method which manage load, loadSerial and loadBefore.
         OID and TID (serial) parameters are expected packed.
-        snapshot_tid
-            First TID not visible to current transaction.
-            Set to None for no limit.
         oid
             OID of object to get.
-        serial
-            If given, the exact serial at which OID is desired.
-            tid should be None.
         tid
+            If given, the exact serial at which OID is desired.
+            before_tid should be None.
+        before_tid
             If given, the excluded upper bound serial at which OID is desired.
             serial should be None.
 
@@ -413,25 +410,19 @@ class Application(object):
                 object doesn't exist
             NEOStorageCreationUndoneError
                 object existed, but its creation was undone
+
+        Note that loadSerial is used during conflict resolution to load
+        object's current version, which is not visible to us normaly (it was
+        committed after our snapshot was taken).
         """
         # TODO:
-        # - rename parameters (here and in handlers & packet definitions)
-        if snapshot_tid is not None:
-            if serial is None:
-                if tid is None:
-                    tid = snapshot_tid
-                else:
-                    tid = min(tid, snapshot_tid)
-            # XXX: we must not clamp serial with snapshot_tid, as loadSerial is
-            # used during conflict resolution to load object's current version,
-            # which is not visible to us normaly (it was committed after our
-            # snapshot was taken).
+        # - rename parameters (here? and in handlers & packet definitions)
 
         self._load_lock_acquire()
         try:
-            result = self._loadFromCache(oid, serial, tid)
+            result = self._loadFromCache(oid, tid, before_tid)
             if not result:
-                result = self._loadFromStorage(oid, serial, tid)
+                result = self._loadFromStorage(oid, tid, before_tid)
                 self._cache_lock_acquire()
                 try:
                     self._cache.store(oid, *result)
@@ -869,11 +860,9 @@ class Application(object):
                 # object. This is an undo conflict, try to resolve it.
                 try:
                     # Load the latest version we are supposed to see
-                    data = self.load(snapshot_tid, oid,
-                        serial=current_serial)[0]
+                    data = self.load(oid, current_serial, snapshot_tid)[0]
                     # Load the version we were undoing to
-                    undo_data = self.load(snapshot_tid, oid,
-                        serial=undo_serial)[0]
+                    undo_data = self.load(oid, undo_serial, snapshot_tid)[0]
                 except NEOStorageNotFoundError:
                     raise UndoError('Object not found while resolving undo '
                         'conflict')
@@ -1084,7 +1073,7 @@ class Application(object):
             self._cache_lock_release()
 
     def getLastTID(self, oid):
-        return self.load(None, oid)[1]
+        return self.load(oid)[1]
 
     def checkCurrentSerialInTransaction(self, oid, serial, transaction):
         txn_context = self._txn_container.get(transaction)

Modified: trunk/neo/client/iterator.py
==============================================================================
--- trunk/neo/client/iterator.py [iso-8859-1] (original)
+++ trunk/neo/client/iterator.py [iso-8859-1] Tue Apr 12 18:16:06 2011
@@ -63,7 +63,7 @@ class Transaction(BaseStorage.Transactio
         while oid_index < oid_len:
             oid = oid_list[oid_index]
             try:
-                data, _, next_tid = app.load(None, oid, serial=self.tid)
+                data, _, next_tid = app.load(oid, self.tid)
             except NEOStorageCreationUndoneError:
                 data = next_tid = None
             except NEOStorageNotFoundError:




More information about the Neo-report mailing list