Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Matevz Golob
erp5
Commits
4371d5c8
Commit
4371d5c8
authored
Mar 04, 2019
by
Bryton Lacquement
🚪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Localizer: update the 'Global Request' monkey-patch to support WSGIPublisher
parent
59212692
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
34 deletions
+33
-34
product/Localizer/patches.py
product/Localizer/patches.py
+33
-34
No files found.
product/Localizer/patches.py
View file @
4371d5c8
...
@@ -28,7 +28,7 @@ from .itools.i18n import AcceptLanguageType
...
@@ -28,7 +28,7 @@ from .itools.i18n import AcceptLanguageType
# Import from Zope
# Import from Zope
import
Globals
import
Globals
from
ZPublisher
import
Publish
from
ZPublisher
import
Publish
,
WSGIPublisher
from
ZPublisher.HTTPRequest
import
HTTPRequest
from
ZPublisher.HTTPRequest
import
HTTPRequest
...
@@ -65,23 +65,19 @@ def get_request():
...
@@ -65,23 +65,19 @@ def get_request():
"""Get a request object"""
"""Get a request object"""
return
_requests
.
get
(
get_ident
(),
None
)
return
_requests
.
get
(
get_ident
(),
None
)
def
get_new_publish
(
zope_publish
):
def
new_publish
(
request
,
module_name
,
after_list
,
debug
=
0
,
def
publish
(
request
,
*
args
,
**
kwargs
):
zope_publish
=
Publish
.
publish
):
# Get the process id
# Get the process id
ident
=
get_ident
()
ident
=
get_ident
()
# Add the request object to the global dictionnary
# Add the request object to the global dictionnary
_requests_lock
.
acquire
()
with
_requests_lock
:
try
:
_requests
[
ident
]
=
request
_requests
[
ident
]
=
request
finally
:
_requests_lock
.
release
()
# Call the old publish
# Call the old publish
try
:
try
:
# Publish
# Publish
x
=
zope_publish
(
request
,
module_name
,
after_list
,
debug
)
return
zope_publish
(
request
,
*
args
,
**
kwargs
)
finally
:
finally
:
# Remove the request object.
# Remove the request object.
# When conflicts occur the "publish" method is called again,
# When conflicts occur the "publish" method is called again,
...
@@ -90,20 +86,23 @@ def new_publish(request, module_name, after_list, debug=0,
...
@@ -90,20 +86,23 @@ def new_publish(request, module_name, after_list, debug=0,
# request does not exist anymore. For this reason we check first
# request does not exist anymore. For this reason we check first
# wether the request is there or not.
# wether the request is there or not.
if
ident
in
_requests
:
if
ident
in
_requests
:
_requests_lock
.
acquire
()
with
_requests_lock
:
try
:
del
_requests
[
ident
]
del
_requests
[
ident
]
finally
:
return
publish
_requests_lock
.
release
()
return
x
if
patch
is
False
:
if
patch
is
False
:
logger
.
info
(
'Install "Globals.get_request".'
)
logger
.
info
(
'Install "Globals.get_request".'
)
# Apply the patch
# Apply the patch
Publish
.
publish
=
new_publish
Publish
.
publish
=
get_new_publish
(
Publish
.
publish
)
WSGIPublisher
.
publish
=
get_new_publish
(
WSGIPublisher
.
publish
)
# Update WSGIPublisher.publish_module.__defaults__, otherwise it will use
# the unpatched WSGIPublisher.publish.
WSGIPublisher
.
publish_module
.
__defaults__
=
(
WSGIPublisher
.
publish
,
)
+
WSGIPublisher
.
publish_module
.
__defaults__
[
1
:]
# First import (it's not a refresh operation).
# First import (it's not a refresh operation).
# We need to apply the patches.
# We need to apply the patches.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment