Commit ecfb1ed3 authored by Nicolas Delaby's avatar Nicolas Delaby

Fix partially r30174, small enhancements

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@30177 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d79934cb
...@@ -95,22 +95,20 @@ class ERP5DocumentConduit(ERP5Conduit): ...@@ -95,22 +95,20 @@ class ERP5DocumentConduit(ERP5Conduit):
prop_list = attribute.split('/') prop_list = attribute.split('/')
prop_id = prop_list[1] prop_id = prop_list[1]
path_prop_id = '//' + prop_id path_prop_id = '//' + prop_id
if data_change.has_key(prop_id): if prop_id not in data_change:
xml = data_change[prop_id] data_change[prop_id] = xml_previous.xpath(path_prop_id)[0]
else: xml = data_change[prop_id]
xml = xml_previous.xpath(path_prop_id)[0]
request = prop_list[-1] request = prop_list[-1]
if getattr(ERP5Diff, '__version__', 0.0) <= 0.2: if getattr(ERP5Diff, '__version__', 0.0) <= 0.2:
#Old ERP5Diff, xpath position start from 0, so add +1 to be compliant #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) request = re.sub('(\d+)', lambda match:str(int(match.group(0))+1), request)
if subnode.xpath('name()') in self.XUPDATE_DEL: if subnode.xpath('name()') in self.XUPDATE_DEL:
node_to_remove_list = xml.xpath(request) node_to_remove_list.extend(xml.xpath(request))
if node_to_remove_list:
xml.remove(node_to_remove_list[0])
data_change[prop_id] = xml
xml_xupdate.remove(subnode) xml_xupdate.remove(subnode)
elif subnode.xpath('name()') in self.XUPDATE_UPDATE: 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) xml_xupdate.remove(subnode)
elif subnode.xpath('name()') in self.XUPDATE_INSERT_OR_ADD: elif subnode.xpath('name()') in self.XUPDATE_INSERT_OR_ADD:
if self.getSubObjectDepth(subnode[0]) == 0: if self.getSubObjectDepth(subnode[0]) == 0:
...@@ -120,10 +118,9 @@ class ERP5DocumentConduit(ERP5Conduit): ...@@ -120,10 +118,9 @@ class ERP5DocumentConduit(ERP5Conduit):
prop_id = attribute.split('/')[2] prop_id = attribute.split('/')[2]
if prop_id in self.data_type_tag_list: if prop_id in self.data_type_tag_list:
path_prop_id = '//' + prop_id path_prop_id = '//' + prop_id
if data_change.has_key(prop_id): if prop_id not in data_change:
xml = data_change[prop_id] data_change[prop_id] = xml_previous.xpath(path_prop_id)[0]
else: xml = data_change[prop_id]
xml = xml_previous.xpath(path_prop_id)[0]
for element in self.getXupdateElementList(subnode): for element in self.getXupdateElementList(subnode):
name_element = element.attrib.get('name', None) name_element = element.attrib.get('name', None)
if name_element: if name_element:
...@@ -135,7 +132,6 @@ class ERP5DocumentConduit(ERP5Conduit): ...@@ -135,7 +132,6 @@ class ERP5DocumentConduit(ERP5Conduit):
block.attrib.update(attrib_dict) block.attrib.update(attrib_dict)
if len(element): if len(element):
block.text = element[-1].tail block.text = element[-1].tail
data_change[prop_id] = xml
xml_xupdate.remove(subnode) xml_xupdate.remove(subnode)
#Remove nodes at the end to avoid changing position of elements #Remove nodes at the end to avoid changing position of elements
...@@ -143,8 +139,7 @@ class ERP5DocumentConduit(ERP5Conduit): ...@@ -143,8 +139,7 @@ class ERP5DocumentConduit(ERP5Conduit):
#apply modification #apply modification
if len(data_change): if len(data_change):
args = {} args = {}
for key in data_change.keys(): for key, node in data_change.iteritems():
node = data_change[key]
node.text = None node.text = None
data = self.convertXmlValue(node) data = self.convertXmlValue(node)
args[key] = data args[key] = data
......
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