[Erp5-report] r29871 - in /erp5/trunk/products: CMFActivity/ ERP5/ ERP5Type/ ERP5Type/patches/
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed Oct 21 15:37:49 CEST 2009
Author: leonardo
Date: Wed Oct 21 15:37:47 2009
New Revision: 29871
URL: http://svn.erp5.org?rev=29871&view=rev
Log:
before-commit-hook API for the transaction object changed. Temporarily patch transaction on Zope 2.8 with the new API and adapt all uses (approved by jm)
Added:
erp5/trunk/products/ERP5Type/patches/TransactionAddBeforeCommitHook.py
Modified:
erp5/trunk/products/CMFActivity/ActivityBuffer.py
erp5/trunk/products/ERP5/InteractionWorkflow.py
erp5/trunk/products/ERP5Type/ZopePatch.py
Modified: erp5/trunk/products/CMFActivity/ActivityBuffer.py
URL: http://svn.erp5.org/erp5/trunk/products/CMFActivity/ActivityBuffer.py?rev=29871&r1=29870&r2=29871&view=diff
==============================================================================
--- erp5/trunk/products/CMFActivity/ActivityBuffer.py [utf8] (original)
+++ erp5/trunk/products/CMFActivity/ActivityBuffer.py [utf8] Wed Oct 21 15:37:47 2009
@@ -27,10 +27,7 @@
from zLOG import LOG, ERROR, INFO
import sys
-try:
- from transaction import get as get_transaction
-except ImportError:
- pass
+import transaction
class ActivityBuffer(TM):
@@ -81,13 +78,11 @@
for activity in activity_dict.itervalues():
activity.registerActivityBuffer(self)
- # In Zope 2.8 (ZODB 3.4), use beforeCommitHook instead of
- # patching Trasaction.
- transaction = get_transaction()
- try:
- transaction.beforeCommitHook(self.tpc_prepare, transaction, activity_tool=activity_tool)
- except AttributeError:
- pass
+ # Notice: The operation below cannot fail silently, or we get errors late
+ # in the transaction that are very hard to understand.
+ transaction.get().addBeforeCommitHook(self.tpc_prepare,
+ (transaction,),
+ dict(activity_tool=activity_tool))
except:
LOG('ActivityBuffer', ERROR, "exception during _begin",
error=sys.exc_info())
Modified: erp5/trunk/products/ERP5/InteractionWorkflow.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/InteractionWorkflow.py?rev=29871&r1=29870&r2=29871&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/InteractionWorkflow.py [utf8] (original)
+++ erp5/trunk/products/ERP5/InteractionWorkflow.py [utf8] Wed Oct 21 15:37:47 2009
@@ -306,7 +306,7 @@
# Execute Before Commit
for script_name in tdef.before_commit_script_name:
script = self.scripts[script_name]
- transaction.get().beforeCommitHook(script, sci)
+ transaction.get().addBeforeCommitHook(script, (sci,))
# Execute "activity" scripts
for script_name in tdef.activate_script_name:
@@ -329,4 +329,4 @@
Globals.InitializeClass(InteractionWorkflowDefinition)
addWorkflowFactory(InteractionWorkflowDefinition, id='interaction_workflow',
- title='Web-configurable interaction workflow')
+ title='Web-configurable interaction workflow')
Modified: erp5/trunk/products/ERP5Type/ZopePatch.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/ZopePatch.py?rev=29871&r1=29870&r2=29871&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/ZopePatch.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/ZopePatch.py [utf8] Wed Oct 21 15:37:47 2009
@@ -56,6 +56,9 @@
from Products.ERP5Type.patches import memcache_client
from Products.ERP5Type.patches import StateChangeInfoPatch
from Products.ERP5Type.patches import OFSPdata
+# Forward Compatibility with Zope 2.12 or CMF 2.2. Remove when we've dropped
+# support for old versions
+from Products.ERP5Type.patches import TransactionAddBeforeCommitHook
# These symbols are required for backward compatibility
from Products.ERP5Type.patches.PropertyManager import ERP5PropertyManager
Added: erp5/trunk/products/ERP5Type/patches/TransactionAddBeforeCommitHook.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/patches/TransactionAddBeforeCommitHook.py?rev=29871&view=auto
==============================================================================
--- erp5/trunk/products/ERP5Type/patches/TransactionAddBeforeCommitHook.py (added)
+++ erp5/trunk/products/ERP5Type/patches/TransactionAddBeforeCommitHook.py [utf8] Wed Oct 21 15:37:47 2009
@@ -1,0 +1,28 @@
+##############################################################################
+#
+# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
+# Copyright (c) 2009 Nexedi SARL 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
+#
+##############################################################################
+
+from transaction._transaction import Transaction
+
+if not hasattr(Transaction, 'addBeforeCommitHook'):
+
+ def Transaction_addBeforeCommitHook(self, hook, args=(), kws=None):
+ if kws is None:
+ kws = {}
+ self.beforeCommitHook(hook, *args, **kws)
+
+ import logging
+ logger = logging.getLogger(__name__)
+ logger.info("Patching Transaction with forward compatibility for "
+ ".addBeforeCommitHook()")
+ Transaction.addBeforeCommitHook = Transaction_addBeforeCommitHook
More information about the Erp5-report
mailing list