From 69b59caceef0ebbbde3d47428974504d3e4b31d2 Mon Sep 17 00:00:00 2001
From: Nicolas Delaby <nicolas@nexedi.com>
Date: Mon, 31 May 2010 15:00:18 +0000
Subject: [PATCH]   - Use new marshaller able to produce Qualified nodes (with
 a namespace)   - Mashalled values are not stored into CDATA node anymore
 longer   - Choose arbitrary namespace for nodes  produce by marshaller:
 http://www.erp5.org/namespaces/marshaller

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@35795 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Type/XMLExportImport.py | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/product/ERP5Type/XMLExportImport.py b/product/ERP5Type/XMLExportImport.py
index dc3555290b..5696d7a2c5 100644
--- a/product/ERP5Type/XMLExportImport.py
+++ b/product/ERP5Type/XMLExportImport.py
@@ -36,11 +36,15 @@ from pickle import Pickler, EMPTY_DICT, MARK, DICT, PyStringMap, DictionaryType
 from xml.sax.saxutils import escape, unescape
 from lxml import etree
 from lxml.etree import Element, SubElement
-from xml.marshal.generic import dumps as marshaler
+from xml_marshaller.xml_marshaller import Marshaller
 from OFS.Image import Pdata
 from zLOG import LOG
 from base64 import standard_b64encode
 
+MARSHALLER_NAMESPACE_URI = 'http://www.erp5.org/namespaces/marshaller'
+marshaller = Marshaller(namespace_uri=MARSHALLER_NAMESPACE_URI,
+                                                            as_tree=True).dumps
+
 class OrderedPickler(Pickler):
     
     dispatch = Pickler.dispatch.copy()
@@ -109,10 +113,9 @@ def Base_asXML(object, root=None):
         else:
           raise ValueError("XMLExportImport failed, the data is undefined")
       elif prop_type in ('lines', 'tokens',):
-        # Use CDATA node to not be taken into account by erp5diff 
         value = [word.decode('utf-8').encode('ascii','xmlcharrefreplace')\
             for word in value]
-        sub_object.text = etree.CDATA(marshaler(value))
+        sub_object.append(marshaller(value))
       elif prop_type in ('text', 'string',):
         sub_object.text = unicode(escape(value), 'utf-8')
       elif prop_type != 'None':
@@ -151,18 +154,18 @@ def Base_asXML(object, root=None):
       if isinstance(role, unicode):
         role = role.encode('utf-8')
       role_list.append(role)
-    local_role_node.text = etree.CDATA(marshaler(tuple(role_list)))
+    local_role_node.append(marshaller(tuple(role_list)))
   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'))
-      local_permission_node.text = etree.CDATA(marshaler(user_permission[1]))
+      local_permission_node.append(marshaller(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'))
-      local_group_node.text = etree.CDATA(marshaler(group_role[1]))
+      local_group_node.append(marshaller(group_role[1]))
   if return_as_object:
     return root
   return etree.tostring(root, encoding='utf-8',
-- 
2.30.9