[Erp5-report] r18572 - /erp5/trunk/products/CMFActivity/ActivityTool.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed Jan 2 11:12:42 CET 2008
Author: vincent
Date: Wed Jan 2 11:12:42 2008
New Revision: 18572
URL: http://svn.erp5.org?rev=18572&view=rev
Log:
Rebuild acquisition chain before invoking a message to use independant request copies for each message execution.
Modified:
erp5/trunk/products/CMFActivity/ActivityTool.py
Modified: erp5/trunk/products/CMFActivity/ActivityTool.py
URL: http://svn.erp5.org/erp5/trunk/products/CMFActivity/ActivityTool.py?rev=18572&r1=18571&r2=18572&view=diff
==============================================================================
--- erp5/trunk/products/CMFActivity/ActivityTool.py (original)
+++ erp5/trunk/products/CMFActivity/ActivityTool.py Wed Jan 2 11:12:42 2008
@@ -778,7 +778,28 @@
activity.stop(aq_inner(self), **kw)
def invoke(self, message):
- message(self)
+ if getattr(self, 'aq_chain', None) is not None:
+ # Grab existing acquisition chain and extrach base objects.
+ base_chain = [aq_base(x) for x in object.aq_chain]
+ # Grab existig request (last chain item) and create a copy.
+ request_container = base_chain.pop()
+ request = request_container.REQUEST
+ # XXX: REQUEST.clone() requires PARENTS to be set, and it's not when
+ # runing unit tests. Recreate it if it does not exist.
+ parents = getattr(request, 'PARENTS', None)
+ if parents is None:
+ LOG('CMFActivity.ActivityTool.invoke', INFO, 'PARENTS is not defined in REQUEST. It should only happen in unit tests.')
+ request['PARENTS'] = object.aq_chain[:]
+ new_request_container = request_container.__class__(REQUEST=request.clone())
+ # Recreate acquisition chain.
+ my_self = new_request_container
+ base_chain.reverse()
+ for item in base_chain:
+ my_self = item.__of__(my_self)
+ else:
+ my_self = self
+ LOG('CMFActivity.ActivityTool.invoke', INFO, 'Strange: invoke is called outside of acquisition context.')
+ message(my_self)
def invokeGroup(self, method_id, message_list):
# Invoke a group method.
More information about the Erp5-report
mailing list