[Neo-report] r2492 vincent - in /trunk/neo: client/ tests/client/

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Dec 9 14:33:09 CET 2010


Author: vincent
Date: Thu Dec  9 14:33:09 2010
New Revision: 2492

Log:
Drop support for getSerial, it's not present in recent ZODB API.

Modified:
    trunk/neo/client/Storage.py
    trunk/neo/client/app.py
    trunk/neo/tests/client/testClientApp.py

Modified: trunk/neo/client/Storage.py
==============================================================================
--- trunk/neo/client/Storage.py [iso-8859-1] (original)
+++ trunk/neo/client/Storage.py [iso-8859-1] Thu Dec  9 14:33:09 2010
@@ -91,12 +91,6 @@ class Storage(BaseStorage.BaseStorage,
         self.app.store(oid=oid, serial=serial, data='', version=None,
             transaction=transaction)
 
-    def getSerial(self, oid):
-        try:
-            return self.app.getSerial(oid = oid)
-        except NEOStorageNotFoundError:
-            raise POSException.POSKeyError(oid)
-
     # mutliple revisions
     def loadSerial(self, oid, serial):
         try:

Modified: trunk/neo/client/app.py
==============================================================================
--- trunk/neo/client/app.py [iso-8859-1] (original)
+++ trunk/neo/client/app.py [iso-8859-1] Thu Dec  9 14:33:09 2010
@@ -437,28 +437,6 @@ class Application(object):
         return int(u64(self.last_oid))
 
     @profiler_decorator
-    def getSerial(self, oid):
-        # Try in cache first
-        self._cache_lock_acquire()
-        try:
-            try:
-                result = self.mq_cache[oid]
-            except KeyError:
-                pass
-            else:
-                return result[0]
-        finally:
-            self._cache_lock_release()
-        # history return serial, so use it
-        hist = self.history(oid, size=1, object_only=1)
-        if len(hist) == 0:
-            raise NEOStorageNotFoundError()
-        if hist[0] != oid:
-            raise NEOStorageError('getSerial failed')
-        return hist[1][0][0]
-
-
-    @profiler_decorator
     def _load(self, oid, serial=None, tid=None, cache=0):
         """
         Internal method which manage load, loadSerial and loadBefore.
@@ -1112,7 +1090,7 @@ class Application(object):
     def transactionLog(self, first, last):
         return self.__undoLog(first, last, with_oids=True)
 
-    def history(self, oid, version=None, size=1, filter=None, object_only=0):
+    def history(self, oid, version=None, size=1, filter=None):
         # Get history informations for object first
         cell_list = self._getCellListForOID(oid, readable=True)
         shuffle(cell_list)
@@ -1145,10 +1123,6 @@ class Application(object):
             # XXX: this may requires an error from the storages
             raise KeyError
 
-        if object_only:
-            # Use by getSerial
-            return self.local_var.history
-
         # Now that we have object informations, get txn informations
         history_list = []
         for serial, size in self.local_var.history[1]:

Modified: trunk/neo/tests/client/testClientApp.py
==============================================================================
--- trunk/neo/tests/client/testClientApp.py [iso-8859-1] (original)
+++ trunk/neo/tests/client/testClientApp.py [iso-8859-1] Thu Dec  9 14:33:09 2010
@@ -199,32 +199,6 @@ class ClientApplicationTests(NeoUnitTest
         self.assertTrue(app.new_oid_list[0] in test_oid_list)
         self.assertNotEqual(app.new_oid_list[0], new_oid)
 
-    def test_getSerial(self):
-        app = self.getApp()
-        mq = app.mq_cache
-        oid = self.makeOID()
-        tid = self.makeTID()
-        # cache cleared
-        self.assertTrue(oid not in mq)
-        app.pt = Mock({ 'getCellListForOID': [], })
-        app.local_var.history = (oid, [(tid, 0)])
-        # If object len is 0, this object doesn't exist anymore because its
-        # creation has been undone.
-        self.assertRaises(KeyError, app.getSerial, oid)
-        self.assertEquals(len(app.pt.mockGetNamedCalls('getCellListForOID')), 1)
-        # Otherwise, result from ZODB
-        app.pt = Mock({ 'getCellListForOID': [], })
-        app.local_var.history = (oid, [(tid, 1)])
-        self.assertEquals(app.getSerial(oid), tid)
-        self.assertEquals(len(app.pt.mockGetNamedCalls('getCellListForOID')), 1)
-        # fill the cache -> hit
-        mq.store(oid, (tid, ' '))
-        self.assertTrue(oid in mq)
-        app.pt = Mock({ 'getCellListForOID': [], })
-        app.getSerial(oid)
-        self.assertEquals(app.getSerial(oid), tid)
-        self.assertEquals(len(app.pt.mockGetNamedCalls('getCellListForOID')), 0)
-
     def test_load(self):
         app = self.getApp()
         app.local_var.barrier_done = True




More information about the Neo-report mailing list