[Erp5-report] r25285 - in /erp5/trunk/products/ERP5SyncML: ./ Conduit/

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Jan 23 17:00:29 CET 2009


Author: nicolas
Date: Fri Jan 23 17:00:29 2009
New Revision: 25285

URL: http://svn.erp5.org?rev=25285&view=rev
Log:
Enable parser option to remove Whitespace between nodes that do not contain data
It's usefull to have pretty_print working when serialize

Modified:
    erp5/trunk/products/ERP5SyncML/Conduit/ERP5Conduit.py
    erp5/trunk/products/ERP5SyncML/ERP5SyncMLMobileServer.py
    erp5/trunk/products/ERP5SyncML/SynchronizationTool.py
    erp5/trunk/products/ERP5SyncML/XMLSyncUtils.py

Modified: erp5/trunk/products/ERP5SyncML/Conduit/ERP5Conduit.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5SyncML/Conduit/ERP5Conduit.py?rev=25285&r1=25284&r2=25285&view=diff
==============================================================================
--- erp5/trunk/products/ERP5SyncML/Conduit/ERP5Conduit.py [utf8] (original)
+++ erp5/trunk/products/ERP5SyncML/Conduit/ERP5Conduit.py [utf8] Fri Jan 23 17:00:29 2009
@@ -41,6 +41,7 @@
 import re
 import cStringIO
 from lxml import etree
+parser = etree.XMLParser(remove_blank_text=True)
 from xml.marshal.generic import loads as unmarshaler
 from zLOG import LOG, INFO, DEBUG
 
@@ -644,7 +645,7 @@
     if isinstance(xml, (str, unicode)):
       if isinstance(xml, unicode):
         xml = xml.encode('utf-8')
-      xml = etree.XML(xml)
+      xml = etree.XML(xml, parser=parser)
     # If we have the xml from the node erp5, we just take the subnode
     if xml.tag == 'erp5':
       xml = xml[0]
@@ -850,7 +851,7 @@
     """
     conflict_list = []
     if isinstance(xupdate, (str, unicode)):
-      xupdate = etree.XML(xupdate)
+      xupdate = etree.XML(xupdate, parser=parser)
     #When xupdate mix different object, (like object and his subobject) we need to treat them separatly
     if self.isMixedXupdate(xupdate):
       #return to updateNode with only one line

Modified: erp5/trunk/products/ERP5SyncML/ERP5SyncMLMobileServer.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5SyncML/ERP5SyncMLMobileServer.py?rev=25285&r1=25284&r2=25285&view=diff
==============================================================================
--- erp5/trunk/products/ERP5SyncML/ERP5SyncMLMobileServer.py [utf8] (original)
+++ erp5/trunk/products/ERP5SyncML/ERP5SyncMLMobileServer.py [utf8] Fri Jan 23 17:00:29 2009
@@ -8,6 +8,7 @@
 import time
 from optparse import OptionParser
 from lxml import etree
+parser = etree.XMLParser(remove_blank_text=True)
 
 class OptionParser(OptionParser):
 
@@ -136,7 +137,7 @@
   """
   find the client url in the text and return it
   """
-  document = etree.XML(text)
+  document = etree.XML(text, parser=parser)
   client_url = '%s' % document.xpath('string(//SyncHdr/Source/LocURI)')
   return client_url 
 

Modified: erp5/trunk/products/ERP5SyncML/SynchronizationTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5SyncML/SynchronizationTool.py?rev=25285&r1=25284&r2=25285&view=diff
==============================================================================
--- erp5/trunk/products/ERP5SyncML/SynchronizationTool.py [utf8] (original)
+++ erp5/trunk/products/ERP5SyncML/SynchronizationTool.py [utf8] Fri Jan 23 17:00:29 2009
@@ -61,6 +61,7 @@
 from zLOG import LOG, TRACE, DEBUG, INFO
 
 from lxml import etree
+parser = etree.XMLParser(remove_blank_text=True)
 
 class TimeoutHTTPConnection(httplib.HTTPConnection):
   """
@@ -1034,7 +1035,7 @@
       if domain.getSyncContentType() == self.CONTENT_TYPE['SYNCML_WBXML']:
         text = self.wbxml2xml(text)
       #LOG('readResponse, text after wbxml :\n', TRACE, text)
-      xml = etree.XML(text)
+      xml = etree.XML(text, parser=parser)
       url = self.getTarget(xml)
       for publication in self.getPublicationList():
         if publication.getPublicationUrl() == url and \

Modified: erp5/trunk/products/ERP5SyncML/XMLSyncUtils.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5SyncML/XMLSyncUtils.py?rev=25285&r1=25284&r2=25285&view=diff
==============================================================================
--- erp5/trunk/products/ERP5SyncML/XMLSyncUtils.py [utf8] (original)
+++ erp5/trunk/products/ERP5SyncML/XMLSyncUtils.py [utf8] Fri Jan 23 17:00:29 2009
@@ -36,6 +36,8 @@
 from lxml import etree
 from lxml.etree import Element
 from lxml.builder import E
+parser = etree.XMLParser(remove_blank_text=True)
+
 from xml.dom import minidom
 
 try:
@@ -340,7 +342,7 @@
     """
     data_node = Element('Data')
     if media_type == self.MEDIA_TYPE['TEXT_XML'] and isinstance(xml_string, str):
-      data_node.append(etree.XML(xml_string))
+      data_node.append(etree.XML(xml_string, parser=parser))
     elif media_type == self.MEDIA_TYPE['TEXT_XML'] and \
          not isinstance(xml_string, str):
       #xml_string could be Partial element if partial XML
@@ -396,7 +398,7 @@
     if not isinstance(xml_string, (str, unicode)):
       data_node.append(xml_string)
     else:
-      data_node.append(etree.XML(xml_string))
+      data_node.append(etree.XML(xml_string, parser=parser))
     xml = (E.Replace(
              E.CmdID('%s' % cmd_id),
              E.Meta(
@@ -672,7 +674,7 @@
     syncml_data = kw.get('syncml_data','')
     result = {'finished':1}
     if isinstance(remote_xml, (str, unicode)):
-      remote_xml = etree.XML(remote_xml)
+      remote_xml = etree.XML(remote_xml, parser=parser)
     if domain.isOneWayFromServer():
       #Do not set object_path_list, subscriber send nothing
       subscriber.setRemainingObjectPathList([])
@@ -968,7 +970,7 @@
             data_subnode = partial_data
           #LOG('applyActionList', DEBUG, 'data_subnode: %s' % data_subnode)
           if subscriber.getMediaType() == self.MEDIA_TYPE['TEXT_XML']:
-            data_subnode = etree.XML(data_subnode)
+            data_subnode = etree.XML(data_subnode, parser=parser)
         else:
           if subscriber.getMediaType() != self.MEDIA_TYPE['TEXT_XML']:
             data_subnode = self.getDataText(action)
@@ -1306,7 +1308,7 @@
       domain.activate(activity='SQLQueue',
                       tag=domain.getId(),
                       priority=self.PRIORITY).activateSyncModif(
-                      domain_relative_url = domain.getRelativeUrl(),
+                      domain_relative_url=domain.getRelativeUrl(),
                       remote_xml=remote_xml,
                       subscriber_relative_url=subscriber.getRelativeUrl(),
                       cmd_id=cmd_id,
@@ -1384,7 +1386,7 @@
       xml_confirmation = result['xml_confirmation']
       cmd_id = result['cmd_id']
       cmd_id_before_getsyncmldata = kw['cmd_id_before_getsyncmldata']
-      remote_xml = etree.XML(kw['remote_xml'])
+      remote_xml = etree.XML(kw['remote_xml'], parser=parser)
       xml_list = kw['xml_list']
       has_status_list = kw['has_status_list']
       has_response = kw['has_response']
@@ -1501,7 +1503,7 @@
 
     if xml_client is not None:
       if isinstance(xml_client, (str, unicode)):
-        xml_client = etree.XML(xml_client)
+        xml_client = etree.XML(xml_client, parser=parser)
       if xml_client.tag != "SyncML":
         LOG('PubSync', INFO, 'This is not a SyncML Message')
         raise ValueError, "Sorry, This is not a SyncML Message"
@@ -1571,7 +1573,7 @@
     else:
       xml_client = msg
       if isinstance(xml_client, (str, unicode)):
-        xml_client = etree.XML(xml_client)
+        xml_client = etree.XML(xml_client, parser=parser)
         status_list = self.getSyncBodyStatusList(xml_client)
         if status_list:
           status_code_syncHdr = status_list[0]['code']
@@ -1598,7 +1600,7 @@
           else:
             response = self.SubSyncModif(subscription, xml_client)
         else:
-            response = self.SubSyncModif(subscription, xml_client)
+          response = self.SubSyncModif(subscription, xml_client)
 
     if RESPONSE is not None:
       RESPONSE.redirect('manageSubscriptions')




More information about the Erp5-report mailing list