Commit a0057254 authored by Nicolas Delaby's avatar Nicolas Delaby

- Fix non asXML recursion for subobjects introduce in r25154

 - Store Marshaler tree in a CDATA node to be compliant with erp5diff


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25190 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 85578ab1
......@@ -2817,11 +2817,11 @@ class Base( CopyContainer,
self.reindexObject(*args, **kw)
security.declareProtected( Permissions.AccessContentsInformation, 'asXML' )
def asXML(self):
def asXML(self, root=None):
"""
Generate an xml text corresponding to the content of this object
"""
return Base_asXML(self)
return Base_asXML(self, root=root)
# Optimized Menu System
security.declarePublic('allowedContentTypes')
......
......@@ -1224,11 +1224,11 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn,
return error_list
security.declareProtected(Permissions.AccessContentsInformation, 'asXML')
def asXML(self, omit_xml_declaration=True):
def asXML(self, omit_xml_declaration=True, root=None):
"""
Generate an xml text corresponding to the content of this object
"""
return Folder_asXML(self, omit_xml_declaration=omit_xml_declaration)
return Folder_asXML(self, omit_xml_declaration=omit_xml_declaration, root=root)
# Optimized Menu System
security.declarePublic('getVisibleAllowedContentTypeList')
......
......@@ -98,8 +98,7 @@ def Base_asXML(object, root=None):
ascii_data = msg.get_payload()
sub_object.text = ascii_data
elif prop_type in ('lines', 'tokens',):
value_as_node = etree.XML(marshaler(value))
sub_object.append(value_as_node)
sub_object.text = etree.CDATA(marshaler(value))
elif prop_type in ('text', 'string',):
sub_object.text = unicode(escape(value), 'utf-8')
elif prop_type != 'None':
......@@ -132,43 +131,41 @@ def Base_asXML(object, root=None):
for user_role in self.get_local_roles():
local_role_node = SubElement(object, 'local_role',
attrib=dict(id=user_role[0], type='tokens'))
role_list_node = etree.XML(marshaler(user_role[1]))
local_role_node.append(role_list_node)
local_role_node.text = etree.CDATA(marshaler(user_role[1]))
if getattr(self, 'get_local_permissions', None) is not None:
for user_permission in self.get_local_permissions():
local_permission_node = SubElement(object, 'local_permission',
attrib=dict(id=user_permission[0], type='tokens'))
permission_list_node = etree.XML(marshaler(user_permission[1]))
local_permission_node.append(permission_list_node)
local_permission_node.text = etree.CDATA(marshaler(user_permission[1]))
# Sometimes theres is roles specified for groups, like with CPS
if getattr(self, 'get_local_group_roles', None) is not None:
for group_role in self.get_local_group_roles():
local_group_node = SubElement(object, 'local_group',
attrib=dict(id=group_role[0], type='tokens'))
group_role_node = etree.XML(marshaler(group_role[1]))
local_group_node.append(group_role_node)
local_group_node.text = etree.CDATA(marshaler(group_role[1]))
if return_as_object:
return root
return etree.tostring(root, encoding='utf-8',
xml_declaration=True, pretty_print=True)
def Folder_asXML(object, omit_xml_declaration=True):
def Folder_asXML(object, omit_xml_declaration=True, root=None):
"""
Generate an xml text corresponding to the content of this object
"""
xml_declaration = not omit_xml_declaration
from Products.ERP5Type.Base import Base
self = object
if root is None:
root = Element('erp5')
Base_asXML(self, root=root)
root_node = root.xpath('/erp5/object')[0]
root_node = root.find('object')
# Make sure the list of sub objects is ordered
id_list = sorted(self.objectIds())
# Append to the xml the xml of subobjects
for id in id_list:
o = self._getOb(id)
if issubclass(o.__class__, Base):
Base_asXML(o, root=root_node)
o.asXML(root=root_node)
return etree.tostring(root, encoding='utf-8',
xml_declaration=xml_declaration, pretty_print=True)
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