Commit afa4a185 authored by Arnaud Fontaine's avatar Arnaud Fontaine

zope4: ZServer removal: Remove Publisher monkey patches.

parent e74de444
...@@ -94,9 +94,6 @@ from Products.ERP5Type.patches import OFSFile ...@@ -94,9 +94,6 @@ from Products.ERP5Type.patches import OFSFile
from Products.ERP5Type.patches import ZSQLMethod from Products.ERP5Type.patches import ZSQLMethod
from Products.ERP5Type.patches import MimetypesRegistry from Products.ERP5Type.patches import MimetypesRegistry
from Products.ERP5Type.patches import users from Products.ERP5Type.patches import users
if six.PY2:
# No ZServer
from Products.ERP5Type.patches import Publish
from Products.ERP5Type.patches import WSGITask from Products.ERP5Type.patches import WSGITask
if six.PY2: if six.PY2:
# XXX-zope4py3: urllib2 removed (see future/backports/urllib/request.py) # XXX-zope4py3: urllib2 removed (see future/backports/urllib/request.py)
......
This diff is collapsed.
...@@ -25,7 +25,7 @@ from DocumentTemplate.DT_String import String ...@@ -25,7 +25,7 @@ from DocumentTemplate.DT_String import String
# Import from Localizer # Import from Localizer
import six import six
if six.PY2: if six.PY2:
from .patches import get_request from . import patches as _
from . import Localizer, MessageCatalog from . import Localizer, MessageCatalog
from .LocalFiles import LocalDTMLFile from .LocalFiles import LocalDTMLFile
......
...@@ -18,65 +18,15 @@ ...@@ -18,65 +18,15 @@
This is a hotfix, it dynamically applies several patches to Zope. This is a hotfix, it dynamically applies several patches to Zope.
""" """
# Import from the Standard Library
import logging
import os
import six
# Import from itools # Import from itools
from .itools.i18n import AcceptLanguageType from .itools.i18n import AcceptLanguageType
# Import from Zope # Import from Zope
from ZPublisher.HTTPRequest import HTTPRequest from ZPublisher.HTTPRequest import HTTPRequest
from zope.globalrequest import clearRequest, setRequest
from zope.globalrequest import getRequest as get_request
# Flag
patch = False patch = False
Z_DEBUG_MODE = os.environ.get('Z_DEBUG_MODE') == '1'
logger = logging.getLogger('Localizer')
# Accept
# PATCH 1: Global Request
#
# This part is obsolete because, we now use zope.globalrequest
#
# The original purpose was to get the request object from places where the
# acquisition was disabled (within the __of__ method for example). It was
# inspired by the Tim McLaughlin's GlobalGetRequest proposal, see
# http://dev.zope.org/Wikis/DevSite/Proposals/GlobalGetRequest
#
# Currently it keeps a Context instance, which wraps the request object,
# but also other things, like the user's session, as it is required by
# the ikaaro CMS.
#
# The request objects are stored in a dictionary in the Publish module,
# whose keys are the thread id.
#
def get_new_publish(zope_publish):
def publish(request, *args, **kwargs):
try:
setRequest(request)
return zope_publish(request, *args, **kwargs)
finally:
clearRequest()
return publish
if patch is False:
patch = True
if six.PY2: # ZServer-specific patch
# Apply the patch TODO: zope4py2 is this really needed ?
from ZPublisher import Publish
Publish.publish = get_new_publish(Publish.publish)
# PATCH 2: Accept
# #
# Adds the variable AcceptLanguage to the REQUEST. It provides a higher # Adds the variable AcceptLanguage to the REQUEST. It provides a higher
# level interface than HTTP_ACCEPT_LANGUAGE. # level interface than HTTP_ACCEPT_LANGUAGE.
...@@ -105,7 +55,7 @@ def new_processInputs(self): ...@@ -105,7 +55,7 @@ def new_processInputs(self):
self.other['AcceptLanguage'] = accept_language self.other['AcceptLanguage'] = accept_language
if patch: if not patch:
HTTPRequest.old_processInputs = HTTPRequest.processInputs HTTPRequest.old_processInputs = HTTPRequest.processInputs
HTTPRequest.processInputs = new_processInputs HTTPRequest.processInputs = new_processInputs
patch = True
...@@ -22,10 +22,6 @@ from .itools.i18n import AcceptLanguageType, init_language_selector ...@@ -22,10 +22,6 @@ from .itools.i18n import AcceptLanguageType, init_language_selector
# Import from Zope # Import from Zope
from App.Common import package_home from App.Common import package_home
# Import from Localizer
from .patches import get_request
# Package home # Package home
ph = package_home(globals()) ph = package_home(globals())
...@@ -42,7 +38,8 @@ def lang_negotiator(available_languages): ...@@ -42,7 +38,8 @@ def lang_negotiator(available_languages):
the list of available languages. Returns the first user pref. language the list of available languages. Returns the first user pref. language
that is available, if none is available returns None. that is available, if none is available returns None.
""" """
request = get_request() from zope.globalrequest import getRequest
request = getRequest()
if request is None: if request is None:
return None return None
......
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