Commit f578a5c8 authored by Aurel's avatar Aurel

Fix bug in xml format for CatalogMethod


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4360 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent de24b0db
...@@ -1014,10 +1014,17 @@ class CatalogMethodTemplateItem(ObjectTemplateItem): ...@@ -1014,10 +1014,17 @@ class CatalogMethodTemplateItem(ObjectTemplateItem):
XMLExportImport.exportXML(object._p_jar, object._p_oid, object_io) XMLExportImport.exportXML(object._p_jar, object._p_oid, object_io)
bta.addObject(object = object_io.getvalue(), name=id+'.filter_instance', path=path) bta.addObject(object = object_io.getvalue(), name=id+'.filter_instance', path=path)
else: else:
xml_data += os.linesep+' <method>' if type(value) in (type(''), type(u'')):
xml_data += os.linesep+' <key>%s</key>' %(method) xml_data += os.linesep+' <method type="">'
xml_data += os.linesep+' <value>%s</value>' %(str(value)) xml_data += os.linesep+' <key>%s</key>' %(method)
xml_data += os.linesep+' </method>' xml_data += os.linesep+' <value>%s</value>' %(str(value))
xml_data += os.linesep+' </method>'
elif type(value) in (type(()), type([])):
xml_data += os.linesep+' <method type="tuple">'
xml_data += os.linesep+' <key>%s</key>' %(method)
for item in value:
xml_data += os.linesep+' <value>%s</value>' %(str(item))
xml_data += os.linesep+' </method>'
xml_data += os.linesep+'</catalog_method>' xml_data += os.linesep+'</catalog_method>'
f.write(str(xml_data)) f.write(str(xml_data))
f.close() f.close()
...@@ -1165,13 +1172,24 @@ class CatalogMethodTemplateItem(ObjectTemplateItem): ...@@ -1165,13 +1172,24 @@ class CatalogMethodTemplateItem(ObjectTemplateItem):
xml = parse(file) xml = parse(file)
method_list = xml.getElementsByTagName('method') method_list = xml.getElementsByTagName('method')
for method in method_list: for method in method_list:
key = method.getElementsByTagName('key')[0].childNodes[0].data type = method.getAttribute('type')
value = method.getElementsByTagName('value')[0].childNodes[0].data if type == "":
key = str(key) key = method.getElementsByTagName('key')[0].childNodes[0].data
if key in catalog_method_list: value = method.getElementsByTagName('value')[0].childNodes[0].data
value = int(value) key = str(key)
if key in catalog_method_list:
value = int(value)
else:
value = str(value)
elif type == "tuple":
value = []
key = method.getElementsByTagName('key')[0].childNodes[0].data
value_list = method.getElementsByTagName('value')
for item in value_list:
value.append(item.childNodes[0].data)
else: else:
value = str(value) LOG('BusinessTemplate import CatalogMethod, type unknown', 0, type)
continue
dict = getattr(self, key) dict = getattr(self, key)
dict[id] = value dict[id] = value
elif '.filter_instance' in file_name: elif '.filter_instance' in file_name:
......
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