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
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Cédric Le Ninivin
erp5
Commits
be9a7d57
Commit
be9a7d57
authored
Jun 01, 2022
by
Cédric Le Ninivin
Committed by
Cédric Le Ninivin
Mar 09, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_api_style: jIOWebSection catches unauthorized Error and return proper error message
parent
930ade4f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
4 deletions
+34
-4
bt5/erp5_api_style/DocumentTemplateItem/portal_components/document.erp5.jIOWebSection.py
...lateItem/portal_components/document.erp5.jIOWebSection.py
+34
-4
No files found.
bt5/erp5_api_style/DocumentTemplateItem/portal_components/document.erp5.jIOWebSection.py
View file @
be9a7d57
...
@@ -28,11 +28,37 @@
...
@@ -28,11 +28,37 @@
##############################################################################
##############################################################################
from
AccessControl
import
ClassSecurityInfo
from
AccessControl
import
ClassSecurityInfo
from
AccessControl
import
Unauthorized
from
Acquisition
import
aq_inner
from
Acquisition
import
aq_inner
from
erp5.component.document.WebSection
import
WebSection
from
erp5.component.document.WebSection
import
WebSection
from
Products.ERP5Type
import
Permissions
from
Products.ERP5Type
import
Permissions
from
zLOG
import
LOG
,
INFO
MARKER
=
[]
MARKER
=
[]
def
convertTojIOAPICall
(
function
):
"""
Wrap the method to create a log entry for each invocation to the zope logger
"""
def
wrapper
(
self
,
*
args
,
**
kwd
):
"""
Log the call, and the result of the call
"""
try
:
retval
=
function
(
self
,
*
args
,
**
kwd
)
except
Unauthorized
,
e
:
LOG
(
'SlapTool'
,
INFO
,
'Converting Unauthorized to Unauthorized error mesage in JSON,'
,
error
=
True
)
return
self
.
ERP5Site_logApiErrorAndReturn
(
error_code
=
"403"
,
error_message
=
str
(
e
),
error_name
=
"Unauthorized"
)
return
'%s'
%
retval
wrapper
.
__doc__
=
function
.
__doc__
return
wrapper
class
jIOWebSection
(
WebSection
):
class
jIOWebSection
(
WebSection
):
"""
"""
This Web Section is a wrapper to jIO to pass content in the body
This Web Section is a wrapper to jIO to pass content in the body
...
@@ -57,6 +83,10 @@ class jIOWebSection(WebSection):
...
@@ -57,6 +83,10 @@ class jIOWebSection(WebSection):
section
=
section
.
aq_parent
section
=
section
.
aq_parent
return
default
return
default
@
convertTojIOAPICall
def
_asjIOStyle
(
self
,
mode
,
text_content
):
return
self
.
ERP5Site_asjIOStyle
(
mode
=
mode
,
text_content
=
text_content
)
security
.
declareProtected
(
Permissions
.
View
,
'get'
)
security
.
declareProtected
(
Permissions
.
View
,
'get'
)
def
get
(
self
):
#pylint:disable=arguments-differ
def
get
(
self
):
#pylint:disable=arguments-differ
"""
"""
...
@@ -64,7 +94,7 @@ class jIOWebSection(WebSection):
...
@@ -64,7 +94,7 @@ class jIOWebSection(WebSection):
__bobo_traverse__ from DocumentExtensibleTraversableMixin is not called
__bobo_traverse__ from DocumentExtensibleTraversableMixin is not called
"""
"""
# Register current web site physical path for later URL generation
# Register current web site physical path for later URL generation
return
self
.
ERP5Site
_asjIOStyle
(
mode
=
"get"
,
text_content
=
self
.
REQUEST
.
get
(
'BODY'
))
return
self
.
_asjIOStyle
(
mode
=
"get"
,
text_content
=
self
.
REQUEST
.
get
(
'BODY'
))
security
.
declareProtected
(
Permissions
.
View
,
'post'
)
security
.
declareProtected
(
Permissions
.
View
,
'post'
)
def
post
(
self
):
def
post
(
self
):
...
@@ -73,7 +103,7 @@ class jIOWebSection(WebSection):
...
@@ -73,7 +103,7 @@ class jIOWebSection(WebSection):
__bobo_traverse__ from DocumentExtensibleTraversableMixin is not called
__bobo_traverse__ from DocumentExtensibleTraversableMixin is not called
"""
"""
# Register current web site physical path for later URL generation
# Register current web site physical path for later URL generation
return
self
.
ERP5Site
_asjIOStyle
(
mode
=
"post"
,
text_content
=
self
.
REQUEST
.
get
(
'BODY'
))
return
self
.
_asjIOStyle
(
mode
=
"post"
,
text_content
=
self
.
REQUEST
.
get
(
'BODY'
))
security
.
declareProtected
(
Permissions
.
View
,
'put'
)
security
.
declareProtected
(
Permissions
.
View
,
'put'
)
def
put
(
self
):
def
put
(
self
):
...
@@ -82,7 +112,7 @@ class jIOWebSection(WebSection):
...
@@ -82,7 +112,7 @@ class jIOWebSection(WebSection):
__bobo_traverse__ from DocumentExtensibleTraversableMixin is not called
__bobo_traverse__ from DocumentExtensibleTraversableMixin is not called
"""
"""
# Register current web site physical path for later URL generation
# Register current web site physical path for later URL generation
return
self
.
ERP5Site
_asjIOStyle
(
mode
=
"put"
,
text_content
=
self
.
REQUEST
.
get
(
'BODY'
))
return
self
.
_asjIOStyle
(
mode
=
"put"
,
text_content
=
self
.
REQUEST
.
get
(
'BODY'
))
security
.
declareProtected
(
Permissions
.
View
,
'allDocs'
)
security
.
declareProtected
(
Permissions
.
View
,
'allDocs'
)
def
allDocs
(
self
):
def
allDocs
(
self
):
...
@@ -91,4 +121,4 @@ class jIOWebSection(WebSection):
...
@@ -91,4 +121,4 @@ class jIOWebSection(WebSection):
__bobo_traverse__ from DocumentExtensibleTraversableMixin is not called
__bobo_traverse__ from DocumentExtensibleTraversableMixin is not called
"""
"""
# Register current web site physical path for later URL generation
# Register current web site physical path for later URL generation
return
self
.
ERP5Site
_asjIOStyle
(
mode
=
"allDocs"
,
text_content
=
self
.
REQUEST
.
get
(
'BODY'
))
return
self
.
_asjIOStyle
(
mode
=
"allDocs"
,
text_content
=
self
.
REQUEST
.
get
(
'BODY'
))
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