[Neo-report] r2658 vincent - /trunk/neo/client/__init__.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed Mar 2 11:24:16 CET 2011
Author: vincent
Date: Wed Mar 2 11:24:16 2011
New Revision: 2658
Log:
Monkey-patch ZODB.Connection.tpc_finish.
This is required since r2534, but was omitted from repository (patch was
posted on zodb-dev, awaiting review).
Modified:
trunk/neo/client/__init__.py
Modified: trunk/neo/client/__init__.py
==============================================================================
--- trunk/neo/client/__init__.py [iso-8859-1] (original)
+++ trunk/neo/client/__init__.py [iso-8859-1] Wed Mar 2 11:24:16 2011
@@ -0,0 +1,51 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Foundation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE
+#
+##############################################################################
+
+# NEO requires ZODB to allow TID to be returned as late as tpc_finish.
+# At the moment, no ZODB release include this patch.
+# Later, this must be replaced by some detection mechanism.
+needs_patch = True
+
+if needs_patch:
+ from ZODB import Connection
+
+ def tpc_finish(self, transaction):
+ """Indicate confirmation that the transaction is done."""
+
+ def callback(tid):
+ if self._mvcc_storage:
+ # Inter-connection invalidation is not needed when the
+ # storage provides MVCC.
+ return
+ d = dict.fromkeys(self._modified)
+ self._db.invalidate(tid, d, self)
+# It's important that the storage calls the passed function
+# while it still has its lock. We don't want another thread
+# to be able to read any updated data until we've had a chance
+# to send an invalidation message to all of the other
+# connections!
+ serial = self._storage.tpc_finish(transaction, callback)
+ if serial is not None:
+ assert isinstance(serial, str), repr(serial)
+ for oid_iterator in (self._modified, self._creating.iterkeys()):
+ for oid in oid_iterator:
+ obj = self._cache.get(oid, None)
+ # Ignore missing objects and don't update ghosts.
+ if obj is not None and obj._p_changed:
+ obj._p_changed = 0
+ obj._p_serial = serial
+ self._tpc_cleanup()
+
+ Connection.tpc_finish = tpc_finish
+
More information about the Neo-report
mailing list