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
Laurent S
erp5
Commits
3803ccf0
Commit
3803ccf0
authored
Feb 01, 2018
by
Tomáš Peterka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[hal_json] Do not crash when form_action is a class method on a plain Python class
parent
4d47c5ab
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
6 deletions
+21
-6
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
...rtal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
+21
-6
No files found.
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.py
View file @
3803ccf0
...
...
@@ -42,6 +42,7 @@ from Products.ERP5Type.Utils import UpperCase
from
Products.ZSQLCatalog.SQLCatalog
import
Query
,
ComplexQuery
from
Products.ERP5Type.Log
import
log
from
collections
import
OrderedDict
from
urlparse
import
urlparse
MARKER
=
[]
...
...
@@ -1303,12 +1304,26 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
# set URL params into REQUEST (just like it was sent by form)
for
query_key
,
query_value
in
query_param_dict
.
items
():
REQUEST
.
set
(
query_key
,
query_value
)
# unfortunatelly some people use Scripts as targets for Workflow
# transactions - thus we need to check and mitigate
if
"Script"
in
renderer_form
.
meta_type
:
# we suppose that the script takes only what is given in the URL params
return
renderer_form
(
**
query_param_dict
)
# Embedded Form can be a Script or even a class method thus we mitigate here
try
:
if
"Script"
in
renderer_form
.
meta_type
:
# we suppose that the script takes only what is given in the URL params
return
renderer_form
(
**
query_param_dict
)
except
AttributeError
:
# if renderer form does not have attr meta_type then it is not a document
# but most likely bound instance method. Some form_ids do actually point to methods.
returned_value
=
renderer_form
(
**
query_param_dict
)
# returned value is usually REQUEST.RESPONSE.redirect()
log
(
'ERP5Document_getHateoas'
,
'HAL_JSON cannot handle returned value "{!s}" from {}({!s})'
.
format
(
returned_value
,
form_id
,
query_param_dict
),
100
)
status_message
=
Base_translateString
(
'Operation executed'
)
if
isinstance
(
returned_value
,
(
str
,
unicode
)):
parsed_url
=
urlparse
(
returned_value
)
parsed_query
=
parse_qs
(
parsed_url
.
query
)
if
len
(
parsed_query
.
get
(
'portal_status_message'
,
()))
>
0
:
status_message
=
parsed_query
.
get
(
'portal_status_message'
)[
0
]
return
traversed_document
.
Base_redirect
(
keep_items
=
{
'portal_status_message'
:
status_message
})
renderForm
(
traversed_document
,
renderer_form
,
embedded_dict
)
result_dict
[
'_embedded'
]
=
{
...
...
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