Commit 5f189b06 authored by Rafael Monnerat's avatar Rafael Monnerat

py3; Fixup _getXmlAsDict

parent 5ad97748
...@@ -30,10 +30,10 @@ from Products.ERP5Type import Permissions ...@@ -30,10 +30,10 @@ from Products.ERP5Type import Permissions
from erp5.component.document.Item import Item from erp5.component.document.Item import Item
from lxml import etree from lxml import etree
import collections import collections
from Products.ERP5Type.Utils import str2bytes, unicode2str, str2unicode
from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
from erp5.component.module.SlapOSCloud import _assertACI from erp5.component.module.SlapOSCloud import _assertACI
from Products.ERP5Type.Utils import unicode2str
from zLOG import LOG, INFO from zLOG import LOG, INFO
try: try:
...@@ -66,16 +66,16 @@ class SoftwareInstance(Item): ...@@ -66,16 +66,16 @@ class SoftwareInstance(Item):
def _getXmlAsDict(self, xml): def _getXmlAsDict(self, xml):
result_dict = {} result_dict = {}
if xml: if xml:
tree = etree.fromstring(xml) tree = etree.fromstring(str2bytes(xml))
for element in tree.iterfind('parameter'): for element in tree.iterfind('parameter'):
key = element.get('id').encode("UTF-8") key = str2unicode(element.get('id'))
value = result_dict.get(key, None) value = result_dict.get(key, None)
if value is not None: if value is not None:
value = (value + ' ' + element.text) value = (value + ' ' + element.text)
else: else:
value = element.text value = element.text
if value is not None: if value is not None:
value = value.encode("UTF-8") value = str2unicode(value)
result_dict[key] = value result_dict[key] = value
return result_dict return result_dict
......
...@@ -36,6 +36,7 @@ from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod ...@@ -36,6 +36,7 @@ from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
from Acquisition import aq_base, aq_inner from Acquisition import aq_base, aq_inner
from slapos.util import dumps from slapos.util import dumps
from lxml import etree from lxml import etree
from Products.ERP5Type.Utils import str2bytes
def cloneDocumentWithANewPortalType(obj, portal_type): def cloneDocumentWithANewPortalType(obj, portal_type):
import erp5.portal_type import erp5.portal_type
...@@ -351,7 +352,7 @@ def isValidXml(self, value, REQUEST=None): ...@@ -351,7 +352,7 @@ def isValidXml(self, value, REQUEST=None):
if REQUEST is not None: if REQUEST is not None:
raise Unauthorized raise Unauthorized
# No better way them this for now # No better way them this for now
etree.fromstring(value) etree.fromstring(str2bytes(value))
return True return True
def isValidXmlMarshaller(self, value, REQUEST=None): def isValidXmlMarshaller(self, value, REQUEST=None):
......
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