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
138
Merge Requests
138
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
8188fba5
Commit
8188fba5
authored
Sep 16, 2021
by
Aurel
Committed by
Arnaud Fontaine
Jan 30, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update patch based on Zope4's code
parent
a46679cf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
104 additions
and
66 deletions
+104
-66
product/ERP5Type/patches/Publish.py
product/ERP5Type/patches/Publish.py
+104
-66
No files found.
product/ERP5Type/patches/Publish.py
View file @
8188fba5
...
@@ -11,34 +11,66 @@
...
@@ -11,34 +11,66 @@
#
#
##############################################################################
##############################################################################
from
Products.ERP5Type.Timeout
import
getPublisherDeadlineValue
from
Products.ERP5Type.Timeout
import
getPublisherDeadlineValue
from
ZPublisher
import
Publish
try
:
from
ZPublisher.Publish
import
(
from
ZServer.ZPublisher
import
Publish
# Produced using:
from
ZServer.ZPublisher.Publish
import
(
# dis.dis(
# Produced using:
# compile(open(<this_file>, 'r').read(), 'foo', 'exec').co_consts[
# dis.dis(
# <index of publish code object in co_consts>
# compile(open(<this_file>, 'r').read(), 'foo', 'exec').co_consts[
# ]
# <index of publish code object in co_consts>
# )
# ]
# and checking all uniques LOAD_GLOBAL names, excluding builtins and
# )
# getPublisherDeadlineValue, and including publish parameter default
# and checking all uniques LOAD_GLOBAL names, excluding builtins and
# values.
# getPublisherDeadlineValue, and including publish parameter default
Retry
,
# values.
call_object
,
ISkinnable
,
dont_publish_class
,
pubevents
,
get_module_info
,
Redirect
,
missing_name
,
Retry
,
publish
,
call_object
,
)
dont_publish_class
,
from
ZPublisher.utils
import
recordMetaData
endInteraction
,
from
zope.publisher.interfaces
import
ISkinnable
get_module_info
,
from
ZPublisher.pubevents
import
PubStart
,
PubBeforeCommit
,
PubAfterTraversal
,
PubBeforeAbort
,
PubFailure
,
PubSuccess
mapply
,
from
zExceptions
import
Redirect
missing_name
,
from
zope.security.management
import
newInteraction
,
endInteraction
newInteraction
,
from
zope.event
import
notify
notify
,
from
ZPublisher.mapply
import
mapply
publish
,
from
zope.publisher.skinnable
import
setDefaultSkin
setDefaultSkin
,
import
sys
sys
,
urlparse
,
)
except
ImportError
:
# BBB Zope2
from
ZPublisher
import
Publish
,
pubevents
from
ZPublisher.Publish
import
(
# Produced using:
# dis.dis(
# compile(open(<this_file>, 'r').read(), 'foo', 'exec').co_consts[
# <index of publish code object in co_consts>
# ]
# )
# and checking all uniques LOAD_GLOBAL names, excluding builtins and
# getPublisherDeadlineValue, and including publish parameter default
# values.
ISkinnable
,
Redirect
,
Retry
,
call_object
,
dont_publish_class
,
endInteraction
,
get_module_info
,
mapply
,
missing_name
,
newInteraction
,
notify
,
publish
,
setDefaultSkin
,
sys
,
urlparse
,
)
def
publish
(
request
,
module_name
,
after_list
,
debug
=
0
,
def
publish
(
request
,
module_name
,
after_list
,
debug
=
0
,
# Optimize:
# Optimize:
call_object
=
call_object
,
call_object
=
call_object
,
...
@@ -55,14 +87,14 @@ def publish(request, module_name, after_list, debug=0,
...
@@ -55,14 +87,14 @@ def publish(request, module_name, after_list, debug=0,
try
:
try
:
with
getPublisherDeadlineValue
(
request
):
with
getPublisherDeadlineValue
(
request
):
notify
(
PubStart
(
request
))
notify
(
pubevents
.
PubStart
(
request
))
# TODO pass request here once BaseRequest implements IParticipation
# TODO pass request here once BaseRequest implements IParticipation
newInteraction
()
newInteraction
()
request
.
processInputs
()
request
.
processInputs
()
request_get
=
request
.
get
request_get
=
request
.
get
response
=
request
.
response
response
=
request
.
response
# First check for "cancel" redirect:
# First check for "cancel" redirect:
if
request_get
(
'SUBMIT'
,
''
).
strip
().
lower
()
==
'cancel'
:
if
request_get
(
'SUBMIT'
,
''
).
strip
().
lower
()
==
'cancel'
:
...
@@ -80,47 +112,50 @@ def publish(request, module_name, after_list, debug=0,
...
@@ -80,47 +112,50 @@ def publish(request, module_name, after_list, debug=0,
if
cancel
:
if
cancel
:
raise
Redirect
(
cancel
)
raise
Redirect
(
cancel
)
after_list
[
0
]
=
bobo_after
after_list
[
0
]
=
bobo_after
if
debug_mode
:
if
debug_mode
:
response
.
debug_mode
=
debug_mode
response
.
debug_mode
=
debug_mode
if
realm
and
not
request
.
get
(
'REMOTE_USER'
,
None
):
if
realm
and
not
request
.
get
(
'REMOTE_USER'
,
None
):
response
.
realm
=
realm
response
.
realm
=
realm
noSecurityManager
()
if
bobo_before
is
not
None
:
if
bobo_before
is
not
None
:
bobo_before
()
bobo_before
()
# Get the path list.
# Get the path list.
# According to RFC1738 a trailing space in the path is valid.
# According to RFC1738 a trailing space in the path is valid.
path
=
request_get
(
'PATH_INFO'
)
path
=
request_get
(
'PATH_INFO'
)
request
[
'PARENTS'
]
=
parents
=
[
object
]
request
[
'PARENTS'
]
=
parents
=
[
object
]
if
transactions_manager
:
if
transactions_manager
:
transactions_manager
.
begin
()
transactions_manager
.
begin
()
object
=
request
.
traverse
(
path
,
validated_hook
=
validated_hook
)
object
=
request
.
traverse
(
path
,
validated_hook
=
validated_hook
)
if
IBrowserPage
.
providedBy
(
object
):
request
.
postProcessInputs
()
notify
(
PubAfterTraversal
(
request
))
notify
(
pubevents
.
PubAfterTraversal
(
request
))
if
transactions_manager
:
if
transactions_manager
:
recordMetaData
(
object
,
request
)
recordMetaData
(
object
,
request
)
result
=
mapply
(
object
,
request
.
args
,
request
,
result
=
mapply
(
object
,
request
.
args
,
request
,
call_object
,
1
,
call_object
,
1
,
missing_name
,
missing_name
,
dont_publish_class
,
dont_publish_class
,
request
,
bind
=
1
)
request
,
bind
=
1
)
if
result
is
not
response
:
if
result
is
not
response
:
response
.
setBody
(
result
)
response
.
setBody
(
result
)
notify
(
PubBeforeCommit
(
request
))
notify
(
pubevents
.
PubBeforeCommit
(
request
))
if
transactions_manager
:
if
transactions_manager
:
transactions_manager
.
commit
()
transactions_manager
.
commit
()
endInteraction
()
notify
(
PubSuccess
(
request
))
notify
(
pubevents
.
PubSuccess
(
request
))
endInteraction
()
return
response
return
response
except
:
except
:
...
@@ -133,47 +168,49 @@ def publish(request, module_name, after_list, debug=0,
...
@@ -133,47 +168,49 @@ def publish(request, module_name, after_list, debug=0,
if
sm
is
not
None
:
if
sm
is
not
None
:
from
asyncore
import
compact_traceback
from
asyncore
import
compact_traceback
cl
,
val
=
sys
.
exc_info
()[:
2
]
cl
,
val
=
sys
.
exc_info
()[:
2
]
sm
(
'%s: %s %s'
%
(
sm
(
'%s: %s %s'
%
(
getattr
(
cl
,
'__name__'
,
cl
),
val
,
getattr
(
cl
,
'__name__'
,
cl
),
val
,
debug_mode
and
compact_traceback
()[
-
1
]
or
''
))
debug_mode
and
compact_traceback
()[
-
1
]
or
''
))
# debug is just used by tests (has nothing to do with debug_mode!)
# debug is just used by tests (has nothing to do with debug_mode!)
if
not
debug
and
err_hook
is
not
None
:
if
not
debug
and
err_hook
is
not
None
:
retry
=
False
retry
=
False
if
parents
:
if
parents
:
parents
=
parents
[
0
]
parents
=
parents
[
0
]
try
:
try
:
try
:
try
:
with
getPublisherDeadlineValue
(
request
):
with
getPublisherDeadlineValue
(
request
):
return
err_hook
(
parents
,
request
,
return
err_hook
(
parents
,
request
,
sys
.
exc_info
()[
0
],
sys
.
exc_info
()[
0
],
sys
.
exc_info
()[
1
],
sys
.
exc_info
()[
1
],
sys
.
exc_info
()[
2
],
sys
.
exc_info
()[
2
],
)
)
except
Retry
:
except
Retry
:
if
not
request
.
supports_retry
():
if
not
request
.
supports_retry
():
with
getPublisherDeadlineValue
(
request
):
with
getPublisherDeadlineValue
(
request
):
return
err_hook
(
parents
,
request
,
return
err_hook
(
parents
,
request
,
sys
.
exc_info
()[
0
],
sys
.
exc_info
()[
0
],
sys
.
exc_info
()[
1
],
sys
.
exc_info
()[
1
],
sys
.
exc_info
()[
2
],
sys
.
exc_info
()[
2
],
)
)
retry
=
True
retry
=
True
finally
:
finally
:
# Note: 'abort's can fail. Nevertheless, we want end request handling
# Note: 'abort's can fail.
# Nevertheless, we want end request handling.
try
:
try
:
try
:
try
:
notify
(
PubBeforeAbort
(
request
,
exc_info
,
retry
))
notify
(
pubevents
.
PubBeforeAbort
(
request
,
exc_info
,
retry
))
finally
:
finally
:
if
transactions_manager
:
if
transactions_manager
:
transactions_manager
.
abort
()
transactions_manager
.
abort
()
finally
:
finally
:
endInteraction
()
endInteraction
()
notify
(
PubFailure
(
request
,
exc_info
,
retry
))
notify
(
pubevents
.
PubFailure
(
request
,
exc_info
,
retry
))
# Only reachable if Retry is raised and request supports retry.
# Only reachable if Retry is raised and request supports retry.
newrequest
=
request
.
retry
()
newrequest
=
request
.
retry
()
request
.
close
()
# Free resources held by the request.
request
.
close
()
# Free resources held by the request.
# Set the default layer/skin on the newly generated request
# Set the default layer/skin on the newly generated request
...
@@ -185,16 +222,17 @@ def publish(request, module_name, after_list, debug=0,
...
@@ -185,16 +222,17 @@ def publish(request, module_name, after_list, debug=0,
newrequest
.
close
()
newrequest
.
close
()
else
:
else
:
# Note: 'abort's can fail. Nevertheless, we want end request handling
# Note: 'abort's can fail.
# Nevertheless, we want end request handling.
try
:
try
:
try
:
try
:
notify
(
PubBeforeAbort
(
request
,
exc_info
,
False
))
notify
(
pubevents
.
PubBeforeAbort
(
request
,
exc_info
,
False
))
finally
:
finally
:
if
transactions_manager
:
if
transactions_manager
:
transactions_manager
.
abort
()
transactions_manager
.
abort
()
finally
:
finally
:
endInteraction
()
endInteraction
()
notify
(
PubFailure
(
request
,
exc_info
,
False
))
notify
(
pubevents
.
PubFailure
(
request
,
exc_info
,
False
))
raise
raise
Publish
.
publish
=
publish
Publish
.
publish
=
publish
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