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
Labels
Merge Requests
139
Merge Requests
139
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
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
4ca4d7f6
Commit
4ca4d7f6
authored
Jun 28, 2019
by
Bryton Lacquement
🚪
2
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip
parent
cdaef829
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
42 deletions
+46
-42
product/ERP5Type/patches/WSGIPublisher.py
product/ERP5Type/patches/WSGIPublisher.py
+46
-42
No files found.
product/ERP5Type/patches/WSGIPublisher.py
View file @
4ca4d7f6
...
...
@@ -307,6 +307,10 @@ def transaction_pubevents(request, response, err_hook, tm=transaction.manager):
del
exc
,
exc_info
finally
:
endInteraction
()
if
transaction
.
manager
.
_txn
is
not
None
:
# Only abort a transaction, if one exists. Otherwise the
# abort creates a new transaction just to abort it.
transaction
.
abort
()
def
publish
(
request
,
module_info
):
...
...
@@ -347,19 +351,12 @@ def publish(request, module_info):
return
response
@
contextmanager
def
load_app
(
module_info
):
app_wrapper
,
realm
,
debug_mode
=
module_info
# Loads the 'OFS.Application' from ZODB.
app
=
app_wrapper
()
def
auto_close_app_iter
(
app
,
app_iter
):
try
:
yield
(
app
,
realm
,
debug_mode
)
yield
for
result
in
app_iter
:
yield
result
finally
:
if
transaction
.
manager
.
_txn
is
not
None
:
# Only abort a transaction, if one exists. Otherwise the
# abort creates a new transaction just to abort it.
transaction
.
abort
()
app
.
_p_jar
.
close
()
...
...
@@ -400,39 +397,46 @@ def publish_module(environ, start_response,
environ
,
new_response
))
for
i
in
range
(
getattr
(
new_request
,
'retry_max_count'
,
3
)
+
1
):
request
=
new_request
response
=
new_response
setRequest
(
request
)
try
:
with
load_app
(
module_info
)
as
new_mod_info
:
app_wrapper
,
realm
,
debug_mode
=
module_info
app
=
app_wrapper
()
try
:
module_info
=
app
,
realm
,
debug_mode
for
i
in
range
(
getattr
(
new_request
,
'retry_max_count'
,
3
)
+
1
):
request
=
new_request
response
=
new_response
setRequest
(
request
)
try
:
with
transaction_pubevents
(
request
,
response
,
err_hook
):
response
=
_publish
(
request
,
new_mod_info
)
break
except
TransientError
:
if
request
.
supports_retry
():
new_request
=
request
.
retry
()
new_response
=
new_request
.
response
else
:
raise
finally
:
request
.
close
()
clearRequest
()
# Start the WSGI server response
status
,
headers
=
response
.
finalize
()
start_response
(
status
,
headers
)
if
isinstance
(
response
.
body
,
_FILE_TYPES
)
or
\
IUnboundStreamIterator
.
providedBy
(
response
.
body
):
result
=
response
.
body
else
:
# If somebody used response.write, that data will be in the
# response.stdout BytesIO, so we put that before the body.
result
=
(
response
.
stdout
.
getvalue
(),
response
.
body
)
response
=
_publish
(
request
,
module_info
)
break
except
TransientError
:
if
request
.
supports_retry
():
new_request
=
request
.
retry
()
new_response
=
new_request
.
response
else
:
raise
finally
:
request
.
close
()
clearRequest
()
# Start the WSGI server response
status
,
headers
=
response
.
finalize
()
start_response
(
status
,
headers
)
for
func
in
response
.
after_list
:
func
()
for
func
in
response
.
after_list
:
func
()
result
=
response
.
body
if
IUnboundStreamIterator
.
providedBy
(
result
):
result
=
auto_close_app_iter
(
app
,
result
)
app
=
next
(
result
)
elif
not
isinstance
(
result
,
_FILE_TYPES
):
# If somebody used response.write, that data will be in the
# response.stdout BytesIO, so we put that before the body.
result
=
response
.
stdout
.
getvalue
(),
result
finally
:
if
app
is
not
None
:
app
.
_p_jar
.
close
()
# Return the result body iterable.
return
result
...
...
Julien Muchembled
@jm
mentioned in merge request
!883 (merged)
·
Jun 28, 2019
mentioned in merge request
!883 (merged)
mentioned in merge request !883
Toggle commit list
Julien Muchembled
@jm
mentioned in merge request
!1489 (merged)
·
Sep 15, 2021
mentioned in merge request
!1489 (merged)
mentioned in merge request !1489
Toggle commit list
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