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
Alain Takoudjou
erp5
Commits
c74ebecd
Commit
c74ebecd
authored
Jan 11, 2016
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5_hal_json_style] Ensure listbox default parameter are loaded as UTF-8, not unicode
parent
d5564ccf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
1 deletion
+29
-1
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.xml
...tal_skins/erp5_hal_json_style/ERP5Document_getHateoas.xml
+12
-1
bt5/erp5_hal_json_style/TestTemplateItem/portal_components/test.erp5.testHalJsonStyle.py
...plateItem/portal_components/test.erp5.testHalJsonStyle.py
+17
-0
No files found.
bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.xml
View file @
c74ebecd
...
...
@@ -68,6 +68,17 @@ if REQUEST is None:\n
if response is None:\n
response = REQUEST.RESPONSE\n
\n
# http://stackoverflow.com/a/13105359\n
def byteify(string):\n
if isinstance(string, dict):\n
return {byteify(key): byteify(value) for key, value in string.iteritems()}\n
elif isinstance(string, list):\n
return [byteify(element) for element in string]\n
elif isinstance(string, unicode):\n
return string.encode(\'utf-8\')\n
else:\n
return string\n
\n
url_template_dict = {\n
"form_action": "%(traversed_document_url)s/%(action_id)s",\n
"traverse_generator": "%(root_url)s/%(script_id)s?mode=traverse" + \\\n
...
...
@@ -954,7 +965,7 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
# context.log(query)\n
catalog_kw = {}\n
if (default_param_json is not None):\n
catalog_kw =
json.loads(urlsafe_b64decode(default_param_json
))\n
catalog_kw =
byteify(json.loads(urlsafe_b64decode(default_param_json)
))\n
if (list_method is None):\n
callable_list_method = portal.portal_catalog\n
else:\n
...
...
bt5/erp5_hal_json_style/TestTemplateItem/portal_components/test.erp5.testHalJsonStyle.py
View file @
c74ebecd
...
...
@@ -745,6 +745,23 @@ class TestERP5Document_getHateoas_mode_search(ERP5HALJSONStyleSkinsMixin):
self
.
assertEqual
(
len
(
result_dict
[
'_embedded'
][
'contents'
]),
0
)
@
simulate
(
'Base_getRequestUrl'
,
'*args, **kwargs'
,
'return "http://example.org/bar"'
)
@
simulate
(
'Base_getRequestHeader'
,
'*args, **kwargs'
,
'return "application/hal+json"'
)
@
changeSkin
(
'Hal'
)
def
test_getHateoas_default_param_json_param
(
self
):
fake_request
=
do_fake_request
(
"GET"
)
self
.
assertRaisesRegexp
(
TypeError
,
# "Unknown columns.*'\\xc3\\xaa'.",
"Unknown columns.*
\
\
\
\
xc3
\
\
\
\
xaa.*"
,
self
.
portal
.
web_site_module
.
hateoas
.
ERP5Document_getHateoas
,
REQUEST
=
fake_request
,
mode
=
"search"
,
default_param_json
=
'eyJcdTAwZWEiOiAiXHUwMGU4In0='
)
class
TestERP5Document_getHateoas_mode_bulk
(
ERP5HALJSONStyleSkinsMixin
):
@
simulate
(
'Base_getRequestHeader'
,
'*args, **kwargs'
,
...
...
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