Commit 08757fd1 authored by Vincent Pelletier's avatar Vincent Pelletier

Rebuild acquisition chain before invoking a message to use independant request...

Rebuild acquisition chain before invoking a message to use independant request copies for each message execution.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18572 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 48a08b27
......@@ -778,7 +778,28 @@ class ActivityTool (Folder, UniqueObject):
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.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment