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
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Romain Courteaud
erp5
Commits
da870a00
Commit
da870a00
authored
Aug 23, 2022
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_hal_json_style: set the locked status only at the end
Prevent potential errors to be returned with 201 status
parent
b9c169f0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
12 deletions
+13
-12
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_redirect.py
...ateItem/portal_skins/erp5_hal_json_style/Base_redirect.py
+13
-12
No files found.
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/Base_redirect.py
View file @
da870a00
...
...
@@ -16,18 +16,6 @@ request_form = context.ERP5Site_filterParameterList(request_form)
request_form
.
update
(
keep_items
)
# XXX Allow CORS
response
=
context
.
REQUEST
.
RESPONSE
context
.
Base_prepareCorsResponse
(
RESPONSE
=
response
)
# http://en.wikipedia.org/wiki/Post/Redirect/Get
response
.
setStatus
(
201
,
lock
=
True
)
response
.
setHeader
(
"X-Location"
,
"urn:jio:get:%s"
%
context
.
getRelativeUrl
())
# be explicit with the reponse content type because in case of reports - they
# can be in text/plain, application/pdf ... so the RJS form needs to know what
# is going exactly on. ERP5Document_getHateoas returns application/hal+json
# therefor we don't need to be afraid of clashes
response
.
setHeader
(
"Content-type"
,
"application/json; charset=utf-8"
)
portal_status_level
=
keep_items
.
pop
(
"portal_status_level"
,
"success"
)
if
portal_status_level
in
(
"warning"
,
"error"
,
"fatal"
):
portal_status_level
=
"error"
...
...
@@ -70,9 +58,22 @@ if (form_id not in [None, 'Base_viewFakePythonScriptActionForm', 'Base_viewFakeJ
)
}
# XXX Allow CORS
response
=
context
.
REQUEST
.
RESPONSE
context
.
Base_prepareCorsResponse
(
RESPONSE
=
response
)
response
.
setHeader
(
"X-Location"
,
"urn:jio:get:%s"
%
context
.
getRelativeUrl
())
# be explicit with the reponse content type because in case of reports - they
# can be in text/plain, application/pdf ... so the RJS form needs to know what
# is going exactly on. ERP5Document_getHateoas returns application/hal+json
# therefor we don't need to be afraid of clashes
response
.
setHeader
(
"Content-type"
,
"application/json; charset=utf-8"
)
result
=
json
.
dumps
(
result_dict
,
indent
=
2
)
# http://en.wikipedia.org/wiki/Post/Redirect/Get
response
.
setStatus
(
201
,
lock
=
True
)
if
abort_transaction
:
response
.
setBody
(
result
,
lock
=
True
)
raise
Redirect
(
''
)
return
result
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