Commit dbef2129 authored by Vincent Pelletier's avatar Vincent Pelletier

PARENTS are stripped by REQUEST.copy(), always recreate them.

Also, recreate them with activity_tool path: originaly, they lead to timer server control panel, which is outside of erp5 site. This way, acquisition using PARENTS value will be able to access objects inside the site.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@20953 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e6801455
...@@ -823,12 +823,18 @@ class ActivityTool (Folder, UniqueObject): ...@@ -823,12 +823,18 @@ class ActivityTool (Folder, UniqueObject):
# Grab existig request (last chain item) and create a copy. # Grab existig request (last chain item) and create a copy.
request_container = base_chain.pop() request_container = base_chain.pop()
request = request_container.REQUEST request = request_container.REQUEST
# Generate PARENTS value. Sadly, we cannot reuse base_chain since
# PARENTS items must be wrapped in acquisition
parents = []
application = self.getPhysicalRoot().aq_base
for parent in self.aq_chain:
if parent.aq_base is application:
break
parents.append(parent)
# XXX: REQUEST.clone() requires PARENTS to be set, and it's not when # XXX: REQUEST.clone() requires PARENTS to be set, and it's not when
# runing unit tests. Recreate it if it does not exist. # runing unit tests. Recreate it if it does not exist.
parents = getattr(request, 'PARENTS', None) if getattr(request.other, 'PARENTS', None) is None:
if parents is None: request.other['PARENTS'] = parents
warn('CMFActivity.ActivityTool.invoke: PARENTS is not defined in REQUEST. It should only happen in unit tests.')
request['PARENTS'] = self.aq_chain[:]
# XXX: itools (used by iHotfix) requires PATH_INFO to be set, and it's # XXX: itools (used by iHotfix) requires PATH_INFO to be set, and it's
# not when runing unit tests. Recreate it if it does not exist. # not when runing unit tests. Recreate it if it does not exist.
if request.environ.get('PATH_INFO') is None: if request.environ.get('PATH_INFO') is None:
...@@ -837,6 +843,8 @@ class ActivityTool (Folder, UniqueObject): ...@@ -837,6 +843,8 @@ class ActivityTool (Folder, UniqueObject):
# restore request information # restore request information
new_request = request.clone() new_request = request.clone()
request_info = message.request_info request_info = message.request_info
# PARENTS is truncated by clone
new_request.other['PARENTS'] = parents
new_request._script = request_info['_script'] new_request._script = request_info['_script']
if 'SERVER_URL' in request_info: if 'SERVER_URL' in request_info:
new_request.other['SERVER_URL'] = request_info['SERVER_URL'] new_request.other['SERVER_URL'] = request_info['SERVER_URL']
......
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