Mercurial > libervia-backend
comparison 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 |
comparison
equal
deleted
inserted
replaced
661:d81f55a58c08 | 662:4f747d7fde8c |
---|---|
215 #the node already exists | 215 #the node already exists |
216 return node | 216 return node |
217 #the node is new | 217 #the node is new |
218 return None | 218 return None |
219 | 219 |
220 def importParams(self, xml): | 220 def updateParams(self, xml): |
221 """import xml in parameters, do nothing if the param already exist | 221 """import xml in parameters, do nothing if the param already exist |
222 @param xml: parameters in xml form""" | 222 @param xml: parameters in xml form""" |
223 src_dom = minidom.parseString(xml.encode('utf-8')) | 223 src_dom = minidom.parseString(xml.encode('utf-8')) |
224 | 224 |
225 def import_node(tgt_parent, src_parent): | 225 def import_node(tgt_parent, src_parent): |
228 continue | 228 continue |
229 node = self.__get_unique_node(tgt_parent, child.nodeName, child.getAttribute("name")) | 229 node = self.__get_unique_node(tgt_parent, child.nodeName, child.getAttribute("name")) |
230 if not node: # The node is new | 230 if not node: # The node is new |
231 tgt_parent.appendChild(child) | 231 tgt_parent.appendChild(child) |
232 else: | 232 else: |
233 import_node(node, child) | 233 if child.nodeName == "param": |
234 # The child update an existing parameter, we replace the node | |
235 tgt_parent.replaceChild(child, node) | |
236 else: | |
237 # the node already exists, we recurse 1 more level | |
238 import_node(node, child) | |
234 | 239 |
235 import_node(self.dom.documentElement, src_dom.documentElement) | 240 import_node(self.dom.documentElement, src_dom.documentElement) |
236 | 241 |
237 def __default_ok(self, value, name, category): | 242 def __default_ok(self, value, name, category): |
238 #FIXME: gof: will not work with individual parameters | 243 #FIXME: gof: will not work with individual parameters |
930 return self.params.getParamsCategories() | 935 return self.params.getParamsCategories() |
931 | 936 |
932 def setParam(self, name, value, category, security_limit=NO_SECURITY_LIMIT, profile_key='@NONE@'): | 937 def setParam(self, name, value, category, security_limit=NO_SECURITY_LIMIT, profile_key='@NONE@'): |
933 return self.params.setParam(name, value, category, security_limit, profile_key) | 938 return self.params.setParam(name, value, category, security_limit, profile_key) |
934 | 939 |
935 def importParams(self, xml): | 940 def updateParams(self, xml): |
936 return self.params.importParams(xml) | 941 return self.params.updateParams(xml) |
937 | 942 |
938 def setDefault(self, name, category, callback, errback=None): | 943 def setDefault(self, name, category, callback, errback=None): |
939 return self.params.setDefault(name, category, callback, errback) | 944 return self.params.setDefault(name, category, callback, errback) |