Commit f766e714 authored by Julien Muchembled's avatar Julien Muchembled

fixup! Localizer: replace the 'Global Request' monkey-patch with zope.globalrequest

parent cdaef829
...@@ -1464,7 +1464,7 @@ class ActivityTool (BaseTool): ...@@ -1464,7 +1464,7 @@ class ActivityTool (BaseTool):
def invoke(self, message): def invoke(self, message):
if self.activity_tracking: if self.activity_tracking:
activity_tracking_logger.info('invoking message: object_path=%s, method_id=%s, args=%r, kw=%r, activity_kw=%r, user_name=%s' % ('/'.join(message.object_path), message.method_id, message.args, message.kw, message.activity_kw, message.user_name)) activity_tracking_logger.info('invoking message: object_path=%s, method_id=%s, args=%r, kw=%r, activity_kw=%r, user_name=%s' % ('/'.join(message.object_path), message.method_id, message.args, message.kw, message.activity_kw, message.user_name))
old_request = None restore_request = False
if getattr(self, 'aq_chain', None) is not None: if getattr(self, 'aq_chain', None) is not None:
# Grab existing acquisition chain and extrach base objects. # Grab existing acquisition chain and extrach base objects.
base_chain = [aq_base(x) for x in self.aq_chain] base_chain = [aq_base(x) for x in self.aq_chain]
...@@ -1501,6 +1501,7 @@ class ActivityTool (BaseTool): ...@@ -1501,6 +1501,7 @@ class ActivityTool (BaseTool):
if 'HTTP_ACCEPT_LANGUAGE' in request_info: 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']
old_request = getRequest() old_request = getRequest()
restore_request = True
setRequest(new_request) setRequest(new_request)
new_request.processInputs() new_request.processInputs()
...@@ -1520,7 +1521,8 @@ class ActivityTool (BaseTool): ...@@ -1520,7 +1521,8 @@ class ActivityTool (BaseTool):
# Restore default skin selection # Restore default skin selection
skinnable = self.getPortalObject() skinnable = self.getPortalObject()
skinnable.changeSkin(skinnable.getSkinNameFromRequest(request)) skinnable.changeSkin(skinnable.getSkinNameFromRequest(request))
setRequest(old_request) if restore_request:
setRequest(old_request)
if self.activity_tracking: if self.activity_tracking:
activity_tracking_logger.info('invoked message') activity_tracking_logger.info('invoked message')
if my_self is not self: # We rewrapped self if my_self is not self: # We rewrapped self
......
...@@ -30,12 +30,9 @@ from ExtensionClass import pmc_init_of ...@@ -30,12 +30,9 @@ from ExtensionClass import pmc_init_of
from DateTime import DateTime from DateTime import DateTime
# XXX make sure that get_request works. # XXX make sure that get_request works.
import Products.ERP5Type.Utils from new import function
from Products.ERP5Type import Globals from zope.globalrequest import getRequest
original_get_request = function(getRequest.__code__, getRequest.__globals__)
# store a copy of the original method
original_get_request = Globals.get_request
convertToUpperCase = Products.ERP5Type.Utils.convertToUpperCase
from Testing.ZopeTestCase.connections import registry from Testing.ZopeTestCase.connections import registry
def get_context(): def get_context():
...@@ -50,8 +47,8 @@ def get_request(): ...@@ -50,8 +47,8 @@ def get_request():
if current_app is not None: if current_app is not None:
return current_app.REQUEST return current_app.REQUEST
Products.ERP5Type.Utils.get_request = get_request sys.modules[getRequest.__module__].get_request = get_request
Globals.get_request = get_request getRequest.__code__ = (lambda: get_request()).__code__
from zope.site.hooks import setSite from zope.site.hooks import setSite
...@@ -62,7 +59,7 @@ from Products.PythonScripts.PythonScript import PythonScript ...@@ -62,7 +59,7 @@ from Products.PythonScripts.PythonScript import PythonScript
from Products.ERP5Type.Accessor.Constant import PropertyGetter as ConstantGetter from Products.ERP5Type.Accessor.Constant import PropertyGetter as ConstantGetter
from Products.ERP5Form.PreferenceTool import Priority from Products.ERP5Form.PreferenceTool import Priority
from zLOG import LOG, DEBUG from zLOG import LOG, DEBUG
from Products.ERP5Type.Utils import convertToUpperCase
from Products.ERP5Type.tests.backportUnittest import SetupSiteError from Products.ERP5Type.tests.backportUnittest import SetupSiteError
from Products.ERP5Type.tests.utils import addUserToDeveloperRole from Products.ERP5Type.tests.utils import addUserToDeveloperRole
from Products.ERP5Type.tests.utils import DummyMailHostMixin, parseListeningAddress from Products.ERP5Type.tests.utils import DummyMailHostMixin, parseListeningAddress
......
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