Commit 6c9d9b5f authored by Romain Courteaud's avatar Romain Courteaud

Fix encoding handling in hypermedia api.

parent 9d52538a
...@@ -82,19 +82,19 @@ else:\n ...@@ -82,19 +82,19 @@ else:\n
assert same_type(dict_data, {})\n assert same_type(dict_data, {})\n
result = "<?xml version=\'1.0\' encoding=\'utf-8\'?><instance>\\n"\n result = "<?xml version=\'1.0\' encoding=\'utf-8\'?><instance>\\n"\n
for key, value in dict_data.items():\n for key, value in dict_data.items():\n
result += """ <parameter id="%s">%s</parameter>\\n""" % (key, value)\n result += """ <parameter id="%s">%s</parameter>\\n""" % (key.encode("UTF-8"), value.encode("UTF-8"))\n
result += "</instance>"\n result += "</instance>"\n
return result\n return result\n
\n \n
try:\n try:\n
parameter_kw = {\n parameter_kw = {\n
\'software_release\': data_dict[\'software_release\'],\n \'software_release\': data_dict[\'software_release\'].encode("UTF-8"),\n
\'software_title\': data_dict[\'title\'],\n \'software_title\': data_dict[\'title\'].encode("UTF-8"),\n
\'software_type\': data_dict[\'software_type\'],\n \'software_type\': data_dict[\'software_type\'].encode("UTF-8"),\n
\'instance_xml\': dictToXml(data_dict[\'parameter\']),\n \'instance_xml\': dictToXml(data_dict[\'parameter\']),\n
\'sla_xml\': dictToXml(data_dict[\'sla\']),\n \'sla_xml\': dictToXml(data_dict[\'sla\']),\n
\'shared\': data_dict[\'slave\'],\n \'shared\': data_dict[\'slave\'],\n
\'state\': data_dict[\'status\'],\n \'state\': data_dict[\'status\'].encode("UTF-8"),\n
}\n }\n
except KeyError:\n except KeyError:\n
response.setStatus(400)\n response.setStatus(400)\n
......
# -*- coding: utf-8 -*-
# Copyright (c) 2002-2013 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2002-2013 Nexedi SA and Contributors. All Rights Reserved.
import transaction import transaction
from Products.SlapOS.tests.testSlapOSMixin import \ from Products.SlapOS.tests.testSlapOSMixin import \
...@@ -95,11 +96,11 @@ class TestSlapOSHypermediaPersonScenario(testSlapOSMixin): ...@@ -95,11 +96,11 @@ class TestSlapOSHypermediaPersonScenario(testSlapOSMixin):
'Content-Type': request_link_dict['type'], 'Content-Type': request_link_dict['type'],
}, },
body=json.dumps({ body=json.dumps({
'software_release': 'http://example.org', 'software_release': 'http://example.orgé',
'title': 'a great title', 'title': 'a great titleé',
'software_type': 'foo', 'software_type': 'fooé',
'parameter': {'param1': 'value1', 'param2': 'value2'}, 'parameter': {'param1é': 'value1é', 'param2é': 'value2é'},
'sla': {'param3': 'value3', 'param4': 'value4'}, 'sla': {'param3é': 'value3é', 'param4é': 'value4é'},
'slave': False, 'slave': False,
'status': 'started', 'status': 'started',
}), }),
......
# -*- coding: utf-8 -*-
# Copyright (c) 2002-2013 Nexedi SA and Contributors. All Rights Reserved. # Copyright (c) 2002-2013 Nexedi SA and Contributors. All Rights Reserved.
import transaction import transaction
from Products.SlapOS.tests.testSlapOSMixin import \ from Products.SlapOS.tests.testSlapOSMixin import \
...@@ -423,11 +424,11 @@ class TestSlapOSPerson_requestHateoasHostingSubscription(testSlapOSMixin): ...@@ -423,11 +424,11 @@ class TestSlapOSPerson_requestHateoasHostingSubscription(testSlapOSMixin):
@simulate('Base_getRequestBody', '*args, **kwargs', @simulate('Base_getRequestBody', '*args, **kwargs',
'return """%s"""' % json.dumps({ 'return """%s"""' % json.dumps({
'software_release': 'http://example.org', 'software_release': 'http://example.orgé',
'title': 'a great title', 'title': 'a great titleé',
'software_type': 'foo', 'software_type': 'fooé',
'parameter': {'param1': 'value1', 'param2': 'value2'}, 'parameter': {'param1é': 'value1é', 'param2é': 'value2é'},
'sla': {'param3': 'value3', 'param4': 'value4'}, 'sla': {'param3': 'value3é', 'param4é': 'value4é'},
'slave': False, 'slave': False,
'status': 'started', 'status': 'started',
})) }))
......
1 2
\ No newline at end of file \ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment