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
Alexander Emmerich
erp5
Commits
4c6840a5
Commit
4c6840a5
authored
Sep 17, 2021
by
Aurel
Committed by
Jérome Perrin
Jan 30, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
differentiate zope2 & 4 patch
parent
c40a723c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
314 additions
and
155 deletions
+314
-155
product/ERP5Type/patches/Publish.py
product/ERP5Type/patches/Publish.py
+314
-155
No files found.
product/ERP5Type/patches/Publish.py
View file @
4c6840a5
...
@@ -39,7 +39,175 @@ try:
...
@@ -39,7 +39,175 @@ try:
setDefaultSkin
,
setDefaultSkin
,
sys
,
sys
,
urlparse
,
urlparse
,
noSecurityManager
,
)
)
def
publish
(
request
,
module_name
,
after_list
,
debug
=
0
,
# Optimize:
call_object
=
call_object
,
missing_name
=
missing_name
,
dont_publish_class
=
dont_publish_class
,
mapply
=
mapply
,
):
(
bobo_before
,
bobo_after
,
object
,
realm
,
debug_mode
,
err_hook
,
validated_hook
,
transactions_manager
)
=
get_module_info
(
module_name
)
parents
=
None
response
=
None
try
:
with
getPublisherDeadlineValue
(
request
):
notify
(
pubevents
.
PubStart
(
request
))
# TODO pass request here once BaseRequest implements IParticipation
newInteraction
()
request
.
processInputs
()
request_get
=
request
.
get
response
=
request
.
response
# First check for "cancel" redirect:
if
request_get
(
'SUBMIT'
,
''
).
strip
().
lower
()
==
'cancel'
:
cancel
=
request_get
(
'CANCEL_ACTION'
,
''
)
if
cancel
:
# Relative URLs aren't part of the spec, but are accepted by
# some browsers.
for
part
,
base
in
zip
(
urlparse
(
cancel
)[:
3
],
urlparse
(
request
[
'BASE1'
])[:
3
]):
if
not
part
:
continue
if
not
part
.
startswith
(
base
):
cancel
=
''
break
if
cancel
:
raise
Redirect
(
cancel
)
after_list
[
0
]
=
bobo_after
if
debug_mode
:
response
.
debug_mode
=
debug_mode
if
realm
and
not
request
.
get
(
'REMOTE_USER'
,
None
):
response
.
realm
=
realm
noSecurityManager
()
if
bobo_before
is
not
None
:
bobo_before
()
# Get the path list.
# According to RFC1738 a trailing space in the path is valid.
path
=
request_get
(
'PATH_INFO'
)
request
[
'PARENTS'
]
=
parents
=
[
object
]
if
transactions_manager
:
transactions_manager
.
begin
()
object
=
request
.
traverse
(
path
,
validated_hook
=
validated_hook
)
if
IBrowserPage
.
providedBy
(
object
):
request
.
postProcessInputs
()
notify
(
pubevents
.
PubAfterTraversal
(
request
))
if
transactions_manager
:
recordMetaData
(
object
,
request
)
result
=
mapply
(
object
,
request
.
args
,
request
,
call_object
,
1
,
missing_name
,
dont_publish_class
,
request
,
bind
=
1
)
if
result
is
not
response
:
response
.
setBody
(
result
)
notify
(
pubevents
.
PubBeforeCommit
(
request
))
if
transactions_manager
:
transactions_manager
.
commit
()
notify
(
pubevents
.
PubSuccess
(
request
))
endInteraction
()
return
response
except
:
# save in order to give 'PubFailure' the original exception info
exc_info
=
sys
.
exc_info
()
# DM: provide nicer error message for FTP
sm
=
None
if
response
is
not
None
:
sm
=
getattr
(
response
,
"setMessage"
,
None
)
if
sm
is
not
None
:
from
asyncore
import
compact_traceback
cl
,
val
=
sys
.
exc_info
()[:
2
]
sm
(
'%s: %s %s'
%
(
getattr
(
cl
,
'__name__'
,
cl
),
val
,
debug_mode
and
compact_traceback
()[
-
1
]
or
''
))
# debug is just used by tests (has nothing to do with debug_mode!)
if
not
debug
and
err_hook
is
not
None
:
retry
=
False
if
parents
:
parents
=
parents
[
0
]
try
:
try
:
with
getPublisherDeadlineValue
(
request
):
return
err_hook
(
parents
,
request
,
sys
.
exc_info
()[
0
],
sys
.
exc_info
()[
1
],
sys
.
exc_info
()[
2
],
)
except
Retry
:
if
not
request
.
supports_retry
():
with
getPublisherDeadlineValue
(
request
):
return
err_hook
(
parents
,
request
,
sys
.
exc_info
()[
0
],
sys
.
exc_info
()[
1
],
sys
.
exc_info
()[
2
],
)
retry
=
True
finally
:
# Note: 'abort's can fail.
# Nevertheless, we want end request handling.
try
:
try
:
notify
(
pubevents
.
PubBeforeAbort
(
request
,
exc_info
,
retry
))
finally
:
if
transactions_manager
:
transactions_manager
.
abort
()
finally
:
endInteraction
()
notify
(
pubevents
.
PubFailure
(
request
,
exc_info
,
retry
))
# Only reachable if Retry is raised and request supports retry.
newrequest
=
request
.
retry
()
request
.
close
()
# Free resources held by the request.
# Set the default layer/skin on the newly generated request
if
ISkinnable
.
providedBy
(
newrequest
):
setDefaultSkin
(
newrequest
)
try
:
return
publish
(
newrequest
,
module_name
,
after_list
,
debug
)
finally
:
newrequest
.
close
()
else
:
# Note: 'abort's can fail.
# Nevertheless, we want end request handling.
try
:
try
:
notify
(
pubevents
.
PubBeforeAbort
(
request
,
exc_info
,
False
))
finally
:
if
transactions_manager
:
transactions_manager
.
abort
()
finally
:
endInteraction
()
notify
(
pubevents
.
PubFailure
(
request
,
exc_info
,
False
))
raise
Publish
.
publish
=
publish
except
ImportError
:
# BBB Zope2
except
ImportError
:
# BBB Zope2
from
ZPublisher
import
Publish
,
pubevents
from
ZPublisher
import
Publish
,
pubevents
from
ZPublisher.Publish
import
(
from
ZPublisher.Publish
import
(
...
@@ -68,171 +236,162 @@ except ImportError: # BBB Zope2
...
@@ -68,171 +236,162 @@ except ImportError: # BBB Zope2
sys
,
sys
,
urlparse
,
urlparse
,
)
)
def
publish
(
request
,
module_name
,
after_list
,
debug
=
0
,
# Optimize:
call_object
=
call_object
,
missing_name
=
missing_name
,
dont_publish_class
=
dont_publish_class
,
mapply
=
mapply
,
):
(
bobo_before
,
bobo_after
,
object
,
realm
,
debug_mode
,
err_hook
,
validated_hook
,
transactions_manager
)
=
get_module_info
(
module_name
)
def
publish
(
request
,
module_name
,
after_list
,
debug
=
0
,
# Optimize:
parents
=
None
call_object
=
call_object
,
response
=
None
missing_name
=
missing_name
,
dont_publish_class
=
dont_publish_class
,
try
:
mapply
=
mapply
,
with
getPublisherDeadlineValue
(
request
):
):
notify
(
PubStart
(
request
))
# TODO pass request here once BaseRequest implements IParticipation
newInteraction
()
request
.
processInputs
()
request_get
=
request
.
get
response
=
request
.
response
# First check for "cancel" redirect:
if
request_get
(
'SUBMIT'
,
''
).
strip
().
lower
()
==
'cancel'
:
cancel
=
request_get
(
'CANCEL_ACTION'
,
''
)
if
cancel
:
# Relative URLs aren't part of the spec, but are accepted by
# some browsers.
for
part
,
base
in
zip
(
urlparse
(
cancel
)[:
3
],
urlparse
(
request
[
'BASE1'
])[:
3
]):
if
not
part
:
continue
if
not
part
.
startswith
(
base
):
cancel
=
''
break
if
cancel
:
raise
Redirect
(
cancel
)
after_list
[
0
]
=
bobo_after
if
debug_mode
:
response
.
debug_mode
=
debug_mode
if
realm
and
not
request
.
get
(
'REMOTE_USER'
,
None
):
response
.
realm
=
realm
if
bobo_before
is
not
None
:
bobo_before
()
# Get the path list.
# According to RFC1738 a trailing space in the path is valid.
path
=
request_get
(
'PATH_INFO'
)
request
[
'PARENTS'
]
=
parents
=
[
object
]
if
transactions_manager
:
transactions_manager
.
begin
()
object
=
request
.
traverse
(
path
,
validated_hook
=
validated_hook
)
notify
(
PubAfterTraversal
(
request
))
(
bobo_before
,
bobo_after
,
object
,
realm
,
debug_mode
,
err_hook
,
if
transactions_manager
:
validated_hook
,
transactions_manager
)
=
get_module_info
(
module_name
)
transactions_manager
.
recordMetaData
(
object
,
request
)
parents
=
None
result
=
mapply
(
object
,
request
.
args
,
request
,
response
=
None
call_object
,
1
,
missing_name
,
try
:
dont_publish_class
,
with
getPublisherDeadlineValue
(
request
):
request
,
bind
=
1
)
notify
(
pubevents
.
PubStart
(
request
))
# TODO pass request here once BaseRequest implements IParticipation
if
result
is
not
response
:
newInteraction
()
response
.
setBody
(
result
)
request
.
processInputs
()
notify
(
PubBeforeCommit
(
request
))
request_get
=
request
.
get
if
transactions_manager
:
response
=
request
.
response
transactions_manager
.
commit
()
endInteraction
()
# First check for "cancel" redirect:
if
request_get
(
'SUBMIT'
,
''
).
strip
().
lower
()
==
'cancel'
:
notify
(
PubSuccess
(
request
))
cancel
=
request_get
(
'CANCEL_ACTION'
,
''
)
if
cancel
:
return
response
# Relative URLs aren't part of the spec, but are accepted by
except
:
# some browsers.
# save in order to give 'PubFailure' the original exception info
for
part
,
base
in
zip
(
urlparse
(
cancel
)[:
3
],
exc_info
=
sys
.
exc_info
()
urlparse
(
request
[
'BASE1'
])[:
3
]):
# DM: provide nicer error message for FTP
if
not
part
:
sm
=
None
continue
if
response
is
not
None
:
if
not
part
.
startswith
(
base
):
sm
=
getattr
(
response
,
"setMessage"
,
None
)
cancel
=
''
break
if
sm
is
not
None
:
if
cancel
:
from
asyncore
import
compact_traceback
raise
Redirect
(
cancel
)
cl
,
val
=
sys
.
exc_info
()[:
2
]
sm
(
'%s: %s %s'
%
(
after_list
[
0
]
=
bobo_after
getattr
(
cl
,
'__name__'
,
cl
),
val
,
if
debug_mode
:
debug_mode
and
compact_traceback
()[
-
1
]
or
''
))
response
.
debug_mode
=
debug_mode
if
realm
and
not
request
.
get
(
'REMOTE_USER'
,
None
):
# debug is just used by tests (has nothing to do with debug_mode!)
response
.
realm
=
realm
if
not
debug
and
err_hook
is
not
None
:
retry
=
False
noSecurityManager
()
if
parents
:
if
bobo_before
is
not
None
:
parents
=
parents
[
0
]
bobo_before
()
# Get the path list.
# According to RFC1738 a trailing space in the path is valid.
path
=
request_get
(
'PATH_INFO'
)
request
[
'PARENTS'
]
=
parents
=
[
object
]
if
transactions_manager
:
transactions_manager
.
begin
()
object
=
request
.
traverse
(
path
,
validated_hook
=
validated_hook
)
if
IBrowserPage
.
providedBy
(
object
):
request
.
postProcessInputs
()
notify
(
pubevents
.
PubAfterTraversal
(
request
))
if
transactions_manager
:
recordMetaData
(
object
,
request
)
result
=
mapply
(
object
,
request
.
args
,
request
,
call_object
,
1
,
missing_name
,
dont_publish_class
,
request
,
bind
=
1
)
if
result
is
not
response
:
response
.
setBody
(
result
)
notify
(
pubevents
.
PubBeforeCommit
(
request
))
if
transactions_manager
:
transactions_manager
.
commit
()
notify
(
pubevents
.
PubSuccess
(
request
))
endInteraction
()
return
response
except
:
# save in order to give 'PubFailure' the original exception info
exc_info
=
sys
.
exc_info
()
# DM: provide nicer error message for FTP
sm
=
None
if
response
is
not
None
:
sm
=
getattr
(
response
,
"setMessage"
,
None
)
if
sm
is
not
None
:
from
asyncore
import
compact_traceback
cl
,
val
=
sys
.
exc_info
()[:
2
]
sm
(
'%s: %s %s'
%
(
getattr
(
cl
,
'__name__'
,
cl
),
val
,
debug_mode
and
compact_traceback
()[
-
1
]
or
''
))
# debug is just used by tests (has nothing to do with debug_mode!)
if
not
debug
and
err_hook
is
not
None
:
retry
=
False
if
parents
:
parents
=
parents
[
0
]
try
:
try
:
try
:
with
getPublisherDeadlineValue
(
request
):
try
:
return
err_hook
(
parents
,
request
,
sys
.
exc_info
()[
0
],
sys
.
exc_info
()[
1
],
sys
.
exc_info
()[
2
],
)
except
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
except
Retry
:
finally
:
if
not
request
.
supports_retry
():
# Note: 'abort's can fail.
with
getPublisherDeadlineValue
(
request
):
# Nevertheless, we want end request handling.
return
err_hook
(
parents
,
request
,
sys
.
exc_info
()[
0
],
sys
.
exc_info
()[
1
],
sys
.
exc_info
()[
2
],
)
retry
=
True
finally
:
# Note: 'abort's can fail. Nevertheless, we want end request handling
try
:
try
:
notify
(
PubBeforeAbort
(
request
,
exc_info
,
retry
))
finally
:
if
transactions_manager
:
transactions_manager
.
abort
()
finally
:
endInteraction
()
notify
(
PubFailure
(
request
,
exc_info
,
retry
))
# Only reachable if Retry is raised and request supports retry.
newrequest
=
request
.
retry
()
request
.
close
()
# Free resources held by the request.
# Set the default layer/skin on the newly generated request
if
ISkinnable
.
providedBy
(
newrequest
):
setDefaultSkin
(
newrequest
)
try
:
return
publish
(
newrequest
,
module_name
,
after_list
,
debug
)
finally
:
newrequest
.
close
()
else
:
# Note: 'abort's can fail. Nevertheless, we want end request handling
try
:
try
:
try
:
try
:
notify
(
pubevents
.
PubBeforeAbort
(
notify
(
PubBeforeAbort
(
request
,
exc_info
,
False
))
request
,
exc_info
,
retry
))
finally
:
finally
:
if
transactions_manager
:
if
transactions_manager
:
transactions_manager
.
abort
()
transactions_manager
.
abort
()
finally
:
finally
:
endInteraction
()
endInteraction
()
notify
(
pubevents
.
PubFailure
(
request
,
exc_info
,
retry
))
notify
(
PubFailure
(
request
,
exc_info
,
False
))
raise
# Only reachable if Retry is raised and request supports retry.
newrequest
=
request
.
retry
()
request
.
close
()
# Free resources held by the request.
# Set the default layer/skin on the newly generated request
if
ISkinnable
.
providedBy
(
newrequest
):
setDefaultSkin
(
newrequest
)
try
:
return
publish
(
newrequest
,
module_name
,
after_list
,
debug
)
finally
:
newrequest
.
close
()
else
:
# Note: 'abort's can fail.
# Nevertheless, we want end request handling.
try
:
try
:
notify
(
pubevents
.
PubBeforeAbort
(
request
,
exc_info
,
False
))
finally
:
if
transactions_manager
:
transactions_manager
.
abort
()
finally
:
endInteraction
()
notify
(
pubevents
.
PubFailure
(
request
,
exc_info
,
False
))
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