[Erp5-report] r30177 - /erp5/trunk/products/ERP5SyncML/Conduit/ERP5DocumentConduit.py

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Oct 30 17:56:54 CET 2009


Author: nicolas
Date: Fri Oct 30 17:56:53 2009
New Revision: 30177

URL: http://svn.erp5.org?rev=30177&view=rev
Log:
Fix partially r30174, small enhancements

Modified:
    erp5/trunk/products/ERP5SyncML/Conduit/ERP5DocumentConduit.py

Modified: erp5/trunk/products/ERP5SyncML/Conduit/ERP5DocumentConduit.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5SyncML/Conduit/ERP5DocumentConduit.py?rev=30177&r1=30176&r2=30177&view=diff
==============================================================================
--- erp5/trunk/products/ERP5SyncML/Conduit/ERP5DocumentConduit.py [utf8] (original)
+++ erp5/trunk/products/ERP5SyncML/Conduit/ERP5DocumentConduit.py [utf8] Fri Oct 30 17:56:53 2009
@@ -95,22 +95,20 @@
         prop_list = attribute.split('/')
         prop_id = prop_list[1]
         path_prop_id = '//' + prop_id
-        if data_change.has_key(prop_id):
-          xml = data_change[prop_id]
-        else:
-          xml = xml_previous.xpath(path_prop_id)[0]
+        if prop_id not in data_change:
+          data_change[prop_id] =  xml_previous.xpath(path_prop_id)[0]
+        xml = data_change[prop_id]
         request = prop_list[-1]
         if getattr(ERP5Diff, '__version__', 0.0) <= 0.2:
           #Old ERP5Diff, xpath position start from 0, so add +1 to be compliant
           request = re.sub('(\d+)', lambda match:str(int(match.group(0))+1), request)
         if subnode.xpath('name()') in self.XUPDATE_DEL:
-          node_to_remove_list = xml.xpath(request)
-          if node_to_remove_list:
-            xml.remove(node_to_remove_list[0]) 
-            data_change[prop_id] = xml
+          node_to_remove_list.extend(xml.xpath(request))
           xml_xupdate.remove(subnode)
         elif subnode.xpath('name()') in self.XUPDATE_UPDATE:
-          node_to_remove_list.extend(xml.xpath(request))
+          #retrieve element in previous_xml
+          element = xml.xpath(request)[0]
+          element.text = subnode.text
           xml_xupdate.remove(subnode)
       elif subnode.xpath('name()') in self.XUPDATE_INSERT_OR_ADD:
         if self.getSubObjectDepth(subnode[0]) == 0:
@@ -120,10 +118,9 @@
             prop_id = attribute.split('/')[2]
             if prop_id in self.data_type_tag_list:
               path_prop_id = '//' + prop_id
-              if data_change.has_key(prop_id):
-                xml = data_change[prop_id]
-              else:
-                xml = xml_previous.xpath(path_prop_id)[0]
+              if prop_id not in data_change:
+                data_change[prop_id] = xml_previous.xpath(path_prop_id)[0]
+              xml = data_change[prop_id]
               for element in self.getXupdateElementList(subnode):
                 name_element = element.attrib.get('name', None)
                 if name_element:
@@ -135,7 +132,6 @@
                   block.attrib.update(attrib_dict)
                   if len(element):
                     block.text = element[-1].tail
-              data_change[prop_id] = xml
               xml_xupdate.remove(subnode)
 
     #Remove nodes at the end to avoid changing position of elements
@@ -143,8 +139,7 @@
     #apply modification
     if len(data_change):
       args = {}
-      for key in data_change.keys():
-        node = data_change[key]
+      for key, node in data_change.iteritems():
         node.text = None
         data = self.convertXmlValue(node)
         args[key] = data




More information about the Erp5-report mailing list