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

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Nov 2 16:29:09 CET 2010


Author: vincent
Date: Tue Nov  2 16:29:04 2010
New Revision: 2406

Log:
Trigger barrier upon first _load call in transaction.

Otherwise, it might not be called (it connector is not present at
transaction manager's "begin" call time).

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] Tue Nov  2 16:29:04 2010
@@ -192,19 +192,3 @@ class Storage(BaseStorage.BaseStorage,
     def close(self):
         self.app.close()
 
-    def invalidationBarrier(self):
-        self.app.invalidationBarrier()
-
-# Monkey-patch ZODB.Connection to fetch all invalidations before starting a
-# transaction.
-from ZODB.Connection import Connection
-# XXX: a better detection should be done if this patch enters ZODB
-INVALIDATION_MARKER = '__INVALIDATION_BARRIER_PATCH_IS_HERE__'
-if not hasattr(Connection, INVALIDATION_MARKER):
-    orig_newTransaction = Connection.newTransaction
-    def newTransaction(self, *ignored):
-        getattr(self._storage, 'invalidationBarrier', lambda: None)()
-        orig_newTransaction(self, *ignored)
-    Connection.newTransaction = newTransaction
-    setattr(Connection, INVALIDATION_MARKER, True)
-

Modified: trunk/neo/client/app.py
==============================================================================
--- trunk/neo/client/app.py [iso-8859-1] (original)
+++ trunk/neo/client/app.py [iso-8859-1] Tue Nov  2 16:29:04 2010
@@ -115,6 +115,7 @@ class ThreadContext(object):
             'asked_object': 0,
             'undo_object_tid_dict': {},
             'involved_nodes': set(),
+            'barrier_done': False,
         }
 
 
@@ -479,6 +480,13 @@ class Application(object):
         """
         # TODO:
         # - rename parameters (here and in handlers & packet definitions)
+
+        # Once per transaction, upon first load, trigger a barrier so we
+        # handle all pending invalidations, so the snapshot of the database is
+        # as up-to-date as possible.
+        if not self.local_var.barrier_done:
+            self.invalidationBarrier()
+            self.local_var.barrier_done = True
         cell_list = self._getCellListForOID(oid, readable=True)
         if len(cell_list) == 0:
             # No cells available, so why are we running ?

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] Tue Nov  2 16:29:04 2010
@@ -227,6 +227,7 @@ class ClientApplicationTests(NeoUnitTest
 
     def test_load(self):
         app = self.getApp()
+        app.local_var.barrier_done = True
         mq = app.mq_cache
         oid = self.makeOID()
         tid1 = self.makeTID(1)
@@ -291,6 +292,7 @@ class ClientApplicationTests(NeoUnitTest
 
     def test_loadSerial(self):
         app = self.getApp()
+        app.local_var.barrier_done = True
         mq = app.mq_cache
         oid = self.makeOID()
         tid1 = self.makeTID(1)
@@ -330,6 +332,7 @@ class ClientApplicationTests(NeoUnitTest
 
     def test_loadBefore(self):
         app = self.getApp()
+        app.local_var.barrier_done = True
         mq = app.mq_cache
         oid = self.makeOID()
         tid1 = self.makeTID(1)





More information about the Neo-report mailing list