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:
self.processing = None
self.user_name = str(_getAuthenticatedUser(self))
# Store REQUEST Info
self.request_info = {}
request = getattr(obj, 'REQUEST', None)
if request is not None:
self.request_info = dict(
SERVER_URL=request.other['SERVER_URL'],
VirtualRootPhysicalPath=request.other.get('VirtualRootPhysicalPath'),
HTTP_ACCEPT_LANGUAGE=request.environ.get('HTTP_ACCEPT_LANGUAGE'),
_script=list(request._script))
if 'SERVER_URL' in request.other:
self.request_info['SERVER_URL'] = request.other['SERVER_URL']
if 'VirtualRootPhysicalPath' in request.other:
self.request_info['VirtualRootPhysicalPath'] = \
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):
"""return the object referenced in this message."""
......@@ -831,14 +836,14 @@ class ActivityTool (Folder, UniqueObject):
# restore request information
new_request = request.clone()
request_info = getattr(message, 'request_info', None)
if request_info is not None:
request_info = message.request_info
new_request._script = request_info['_script']
if 'SERVER_URL' in request_info:
new_request.other['SERVER_URL'] = request_info['SERVER_URL']
virtual_root_path = request_info.get('VirtualRootPhysicalPath')
if virtual_root_path:
new_request.other['VirtualRootPhysicalPath'] = virtual_root_path
if 'VirtualRootPhysicalPath' in request_info:
new_request.other['VirtualRootPhysicalPath'] = request_info['VirtualRootPhysicalPath']
if 'HTTP_ACCEPT_LANGUAGE' in request_info:
new_request.environ['HTTP_ACCEPT_LANGUAGE'] = request_info['HTTP_ACCEPT_LANGUAGE']
new_request._script = request_info['_script']
# Replace iHotfix Context, saving existing one
ihotfix_context = iHotfix.Context(new_request)
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