From 3c1745d8c43f917256d800f0d2f1051b6756e6aa Mon Sep 17 00:00:00 2001 From: Nicolas Delaby <nicolas@nexedi.com> Date: Fri, 30 Oct 2009 16:45:08 +0000 Subject: [PATCH] Postpone remove of nodes, because position is used to locate nodes to update or remove git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@30174 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5SyncML/Conduit/ERP5DocumentConduit.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/product/ERP5SyncML/Conduit/ERP5DocumentConduit.py b/product/ERP5SyncML/Conduit/ERP5DocumentConduit.py index 83c55e4e64..6850ac82e8 100644 --- a/product/ERP5SyncML/Conduit/ERP5DocumentConduit.py +++ b/product/ERP5SyncML/Conduit/ERP5DocumentConduit.py @@ -86,6 +86,7 @@ class ERP5DocumentConduit(ERP5Conduit): from copy import deepcopy xml_previous = deepcopy(previous_xml) #retrieve new data + node_to_remove_list = [] for subnode in xml_xupdate: sub_xupdate = self.getSubObjectXupdate(subnode) attribute = sub_xupdate.attrib.get('select', None) @@ -109,10 +110,7 @@ class ERP5DocumentConduit(ERP5Conduit): data_change[prop_id] = xml xml_xupdate.remove(subnode) elif subnode.xpath('name()') in self.XUPDATE_UPDATE: - #retrieve element in previous_xml - element = xml.xpath(request)[0] - element.text = subnode.text - data_change[prop_id] = xml + node_to_remove_list.extend(xml.xpath(request)) xml_xupdate.remove(subnode) elif subnode.xpath('name()') in self.XUPDATE_INSERT_OR_ADD: if self.getSubObjectDepth(subnode[0]) == 0: @@ -141,6 +139,8 @@ class ERP5DocumentConduit(ERP5Conduit): data_change[prop_id] = xml xml_xupdate.remove(subnode) + #Remove nodes at the end to avoid changing position of elements + [node.getparent().remove(node) for node in node_to_remove_list] #apply modification if len(data_change): args = {} -- 2.30.9