Mercurial > libervia-backend
comparison src/memory/memory.py @ 833:9bac2fc74968
memory: bug fix to not register twice frontends parameters + added some tests for param update
author | souliane <souliane@mailoo.org> |
---|---|
date | Fri, 07 Feb 2014 17:10:24 +0100 |
parents | 1a1600491d9d |
children | f3513c8cc2e6 |
comparison
equal
deleted
inserted
replaced
832:c4b22aedb7d7 | 833:9bac2fc74968 |
---|---|
294 return node | 294 return node |
295 #the node is new | 295 #the node is new |
296 return None | 296 return None |
297 | 297 |
298 def updateParams(self, xml, security_limit=NO_SECURITY_LIMIT, app=''): | 298 def updateParams(self, xml, security_limit=NO_SECURITY_LIMIT, app=''): |
299 """import xml in parameters, do nothing if the param already exist | 299 """import xml in parameters, update if the param already exists |
300 If security_limit is specified and greater than -1, the parameters | 300 If security_limit is specified and greater than -1, the parameters |
301 that have a security level greater than security_limit are skipped. | 301 that have a security level greater than security_limit are skipped. |
302 @param xml: parameters in xml form | 302 @param xml: parameters in xml form |
303 @param security_limit: -1 means no security, 0 is the maximum security then the higher the less secure | 303 @param security_limit: -1 means no security, 0 is the maximum security then the higher the less secure |
304 @param app: name of the frontend registering the parameters or empty value | 304 @param app: name of the frontend registering the parameters or empty value |
337 node = self.__get_unique_node(tgt_parent, child.nodeName, child.getAttribute("name")) | 337 node = self.__get_unique_node(tgt_parent, child.nodeName, child.getAttribute("name")) |
338 if not node: # The node is new | 338 if not node: # The node is new |
339 tgt_parent.appendChild(child) | 339 tgt_parent.appendChild(child) |
340 else: | 340 else: |
341 if child.nodeName == "param": | 341 if child.nodeName == "param": |
342 # The child update an existing parameter, we replace the node | 342 # The child updates an existing parameter, we replace the node |
343 tgt_parent.replaceChild(child, node) | 343 tgt_parent.replaceChild(child, node) |
344 else: | 344 else: |
345 # the node already exists, we recurse 1 more level | 345 # the node already exists, we recurse 1 more level |
346 import_node(node, child) | 346 import_node(node, child) |
347 | 347 |
359 """ | 359 """ |
360 if not app: | 360 if not app: |
361 warning(_("Trying to register frontends parameters with no specified app: aborted")) | 361 warning(_("Trying to register frontends parameters with no specified app: aborted")) |
362 return | 362 return |
363 if not hasattr(self, "frontends_cache"): | 363 if not hasattr(self, "frontends_cache"): |
364 self.frontends_cache = {} | 364 self.frontends_cache = [] |
365 if app in self.frontends_cache: | 365 if app in self.frontends_cache: |
366 warning(_("Trying to register twice frontends parameters for %(app)s: aborted" % {"app": app})) | 366 debug(_("Trying to register twice frontends parameters for %(app)s: aborted" % {"app": app})) |
367 return | 367 return |
368 self.frontends_cache.append(app) | |
368 self.updateParams(xml, security_limit, app) | 369 self.updateParams(xml, security_limit, app) |
369 debug("Frontends parameters registered for %(app)s" % {'app': app}) | 370 debug("Frontends parameters registered for %(app)s" % {'app': app}) |
370 | 371 |
371 def __default_ok(self, value, name, category): | 372 def __default_ok(self, value, name, category): |
372 #FIXME: will not work with individual parameters | 373 #FIXME: will not work with individual parameters |