Commit f7d8bdae authored by Vincent Pelletier's avatar Vincent Pelletier

Always define request_info on message instances.

Do not loose information about presence or not of saved request values (do not use "get").
Only recreate a iHotfix context if a language is available in request: otherwise, translating will fail loudly. If no context is defined, translation will still fail, but silently. Sigh.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@20943 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9e25141e
...@@ -140,13 +140,18 @@ class Message: ...@@ -140,13 +140,18 @@ class Message:
self.processing = None self.processing = None
self.user_name = str(_getAuthenticatedUser(self)) self.user_name = str(_getAuthenticatedUser(self))
# Store REQUEST Info # Store REQUEST Info
self.request_info = {}
request = getattr(obj, 'REQUEST', None) request = getattr(obj, 'REQUEST', None)
if request is not None: if request is not None:
self.request_info = dict( if 'SERVER_URL' in request.other:
SERVER_URL=request.other['SERVER_URL'], self.request_info['SERVER_URL'] = request.other['SERVER_URL']
VirtualRootPhysicalPath=request.other.get('VirtualRootPhysicalPath'), if 'VirtualRootPhysicalPath' in request.other:
HTTP_ACCEPT_LANGUAGE=request.environ.get('HTTP_ACCEPT_LANGUAGE'), self.request_info['VirtualRootPhysicalPath'] = \
_script=list(request._script)) request.other['VirtualRootPhysicalPath']
if 'HTTP_ACCEPT_LANGUAGE' in request.environ:
self.request_info['HTTP_ACCEPT_LANGUAGE'] = \
request.environ['HTTP_ACCEPT_LANGUAGE']
self.request_info['_script'] = list(request._script)
def getObject(self, activity_tool): def getObject(self, activity_tool):
"""return the object referenced in this message.""" """return the object referenced in this message."""
...@@ -831,14 +836,14 @@ class ActivityTool (Folder, UniqueObject): ...@@ -831,14 +836,14 @@ class ActivityTool (Folder, UniqueObject):
# restore request information # restore request information
new_request = request.clone() new_request = request.clone()
request_info = getattr(message, 'request_info', None) request_info = message.request_info
if request_info is not None: new_request._script = request_info['_script']
if 'SERVER_URL' in request_info:
new_request.other['SERVER_URL'] = request_info['SERVER_URL'] new_request.other['SERVER_URL'] = request_info['SERVER_URL']
virtual_root_path = request_info.get('VirtualRootPhysicalPath') if 'VirtualRootPhysicalPath' in request_info:
if virtual_root_path: new_request.other['VirtualRootPhysicalPath'] = request_info['VirtualRootPhysicalPath']
new_request.other['VirtualRootPhysicalPath'] = virtual_root_path if 'HTTP_ACCEPT_LANGUAGE' in request_info:
new_request.environ['HTTP_ACCEPT_LANGUAGE'] = request_info['HTTP_ACCEPT_LANGUAGE'] new_request.environ['HTTP_ACCEPT_LANGUAGE'] = request_info['HTTP_ACCEPT_LANGUAGE']
new_request._script = request_info['_script']
# Replace iHotfix Context, saving existing one # Replace iHotfix Context, saving existing one
ihotfix_context = iHotfix.Context(new_request) ihotfix_context = iHotfix.Context(new_request)
id = get_ident() id = get_ident()
......
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