Commit e579ac1f authored by Jérome Perrin's avatar Jérome Perrin

Localizer 1.2 includes iHotFix, so contexts and locks from iHotFix now have

another location. Add support for both Localizer and iHotFix locations, and
rename variables to use "localizer" name.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25376 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 6ccfbd4a
...@@ -49,7 +49,19 @@ from Acquisition import aq_inner ...@@ -49,7 +49,19 @@ from Acquisition import aq_inner
from ActivityBuffer import ActivityBuffer from ActivityBuffer import ActivityBuffer
from zExceptions import ExceptionFormatter from zExceptions import ExceptionFormatter
from BTrees.OIBTree import OIBTree from BTrees.OIBTree import OIBTree
from Products import iHotfix
try:
from Products import iHotfix
localizer_lock = iHotfix._the_lock
localizer_contexts = iHotfix.contexts
LocalizerContext = iHotfix.Context
except ImportError:
# Localizer 1.2 includes iHotFix patches
import Products.Localizer.patches
localizer_lock = Products.Localizer.patches._requests_lock
localizer_contexts = Products.Localizer.patches._requests
LocalizerContext = lambda request: request
from ZODB.POSException import ConflictError from ZODB.POSException import ConflictError
from Products.MailHost.MailHost import MailHostError from Products.MailHost.MailHost import MailHostError
...@@ -1036,7 +1048,7 @@ class ActivityTool (Folder, UniqueObject): ...@@ -1036,7 +1048,7 @@ class ActivityTool (Folder, UniqueObject):
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=%s, kw=%s, activity_kw=%s, 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=%s, kw=%s, activity_kw=%s, user_name=%s' % ('/'.join(message.object_path), message.method_id, message.args, message.kw, message.activity_kw, message.user_name))
old_ihotfix_context = False old_localizer_context = 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]
...@@ -1055,7 +1067,7 @@ class ActivityTool (Folder, UniqueObject): ...@@ -1055,7 +1067,7 @@ class ActivityTool (Folder, UniqueObject):
# runing unit tests. Recreate it if it does not exist. # runing unit tests. Recreate it if it does not exist.
if getattr(request.other, 'PARENTS', None) is None: if getattr(request.other, 'PARENTS', None) is None:
request.other['PARENTS'] = parents request.other['PARENTS'] = parents
# XXX: itools (used by iHotfix) requires PATH_INFO to be set, and it's # XXX: itools (used by Localizer) 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:
request.environ['PATH_INFO'] = '/Control_Panel/timer_service/process_timer' request.environ['PATH_INFO'] = '/Control_Panel/timer_service/process_timer'
...@@ -1072,16 +1084,16 @@ class ActivityTool (Folder, UniqueObject): ...@@ -1072,16 +1084,16 @@ class ActivityTool (Folder, UniqueObject):
new_request.other['VirtualRootPhysicalPath'] = request_info['VirtualRootPhysicalPath'] new_request.other['VirtualRootPhysicalPath'] = request_info['VirtualRootPhysicalPath']
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']
# Replace iHotfix Context, saving existing one # Replace Localizer/iHotfix Context, saving existing one
ihotfix_context = iHotfix.Context(new_request) localizer_context = LocalizerContext(new_request)
id = get_ident() id = get_ident()
iHotfix._the_lock.acquire() localizer_lock.acquire()
try: try:
old_ihotfix_context = iHotfix.contexts.get(id) old_localizer_context = localizer_contexts.get(id)
iHotfix.contexts[id] = ihotfix_context localizer_contexts[id] = localizer_context
finally: finally:
iHotfix._the_lock.release() localizer_lock.release()
# Execute iHotfix "patch 2" # Execute Localizer/iHotfix "patch 2"
new_request.processInputs() new_request.processInputs()
new_request_container = request_container.__class__(REQUEST=new_request) new_request_container = request_container.__class__(REQUEST=new_request)
...@@ -1100,17 +1112,17 @@ class ActivityTool (Folder, UniqueObject): ...@@ -1100,17 +1112,17 @@ class ActivityTool (Folder, UniqueObject):
# Restore default skin selection # Restore default skin selection
skinnable = self.getPortalObject() skinnable = self.getPortalObject()
skinnable.changeSkin(skinnable.getSkinNameFromRequest(request)) skinnable.changeSkin(skinnable.getSkinNameFromRequest(request))
if old_ihotfix_context is not False: if old_localizer_context is not False:
# Restore iHotfix context # Restore Localizer/iHotfix context
id = get_ident() id = get_ident()
iHotfix._the_lock.acquire() localizer_lock.acquire()
try: try:
if old_ihotfix_context is None: if old_localizer_context is None:
del iHotfix.contexts[id] del localizer_contexts[id]
else: else:
iHotfix.contexts[id] = old_ihotfix_context localizer_contexts[id] = old_localizer_context
finally: finally:
iHotfix._the_lock.release() localizer_lock.release()
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
......
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