memory: bug fix to not register twice frontends parameters + added some tests for param update

This commit is contained in:
souliane 2014-02-07 17:10:24 +01:00
commit 7ea4dca1b0
4 changed files with 66 additions and 30 deletions

View file

@ -296,7 +296,7 @@ class Params(object):
return None
def updateParams(self, xml, security_limit=NO_SECURITY_LIMIT, app=''):
"""import xml in parameters, do nothing if the param already exist
"""import xml in parameters, update if the param already exists
If security_limit is specified and greater than -1, the parameters
that have a security level greater than security_limit are skipped.
@param xml: parameters in xml form
@ -339,7 +339,7 @@ class Params(object):
tgt_parent.appendChild(child)
else:
if child.nodeName == "param":
# The child update an existing parameter, we replace the node
# The child updates an existing parameter, we replace the node
tgt_parent.replaceChild(child, node)
else:
# the node already exists, we recurse 1 more level
@ -361,10 +361,11 @@ class Params(object):
warning(_("Trying to register frontends parameters with no specified app: aborted"))
return
if not hasattr(self, "frontends_cache"):
self.frontends_cache = {}
self.frontends_cache = []
if app in self.frontends_cache:
warning(_("Trying to register twice frontends parameters for %(app)s: aborted" % {"app": app}))
debug(_("Trying to register twice frontends parameters for %(app)s: aborted" % {"app": app}))
return
self.frontends_cache.append(app)
self.updateParams(xml, security_limit, app)
debug("Frontends parameters registered for %(app)s" % {'app': app})