diff src/memory/memory.py @ 662:4f747d7fde8c

core: importParams renamed to updateParams: it now updates the parameter instead of appending children if it find an existing one.
author Goffi <goffi@goffi.org>
date Thu, 31 Oct 2013 17:14:15 +0100
parents 7d6e5807504a
children ffb716804580
line wrap: on
line diff
--- a/src/memory/memory.py	Tue Oct 15 23:10:31 2013 +0200
+++ b/src/memory/memory.py	Thu Oct 31 17:14:15 2013 +0100
@@ -217,7 +217,7 @@
         #the node is new
         return None
 
-    def importParams(self, xml):
+    def updateParams(self, xml):
         """import xml in parameters, do nothing if the param already exist
         @param xml: parameters in xml form"""
         src_dom = minidom.parseString(xml.encode('utf-8'))
@@ -230,7 +230,12 @@
                 if not node:  # The node is new
                     tgt_parent.appendChild(child)
                 else:
-                    import_node(node, child)
+                    if child.nodeName == "param":
+                        # The child update an existing parameter, we replace the node
+                        tgt_parent.replaceChild(child, node)
+                    else:
+                        # the node already exists, we recurse 1 more level
+                        import_node(node, child)
 
         import_node(self.dom.documentElement, src_dom.documentElement)
 
@@ -932,8 +937,8 @@
     def setParam(self, name, value, category, security_limit=NO_SECURITY_LIMIT, profile_key='@NONE@'):
         return self.params.setParam(name, value, category, security_limit, profile_key)
 
-    def importParams(self, xml):
-        return self.params.importParams(xml)
+    def updateParams(self, xml):
+        return self.params.updateParams(xml)
 
     def setDefault(self, name, category, callback, errback=None):
         return self.params.setDefault(name, category, callback, errback)