core: use of Const for profile_key + replaced '@DEFAULT@' default profile_key by '@NONE@'
This commit is contained in:
parent
2a40da1664
commit
005ec59a8a
25 changed files with 123 additions and 101 deletions
|
|
@ -176,7 +176,7 @@ class Params(object):
|
|||
info(_('No profile exist yet'))
|
||||
return ""
|
||||
return default # FIXME: temporary, must use real default value, and fallback to first one if it doesn't exists
|
||||
elif profile_key == '@NONE@':
|
||||
elif profile_key == C.PROF_KEY_NONE:
|
||||
raise exceptions.ProfileNotSetError
|
||||
elif return_profile_keys and profile_key in ["@ALL@"]:
|
||||
return profile_key # this value must be managed by the caller
|
||||
|
|
@ -323,11 +323,11 @@ class Params(object):
|
|||
return "true" if result else "false"
|
||||
return result
|
||||
|
||||
def getStringParamA(self, name, category, attr="value", profile_key="@NONE@"):
|
||||
def getStringParamA(self, name, category, attr="value", profile_key=C.PROF_KEY_NONE):
|
||||
""" Same as getParamA but for bridge: convert non string value to string """
|
||||
return self.__type_to_string(self.getParamA(name, category, attr, profile_key))
|
||||
|
||||
def getParamA(self, name, category, attr="value", profile_key="@NONE@"):
|
||||
def getParamA(self, name, category, attr="value", profile_key=C.PROF_KEY_NONE):
|
||||
"""Helper method to get a specific attribute
|
||||
@param name: name of the parameter
|
||||
@param category: category of the parameter
|
||||
|
|
@ -360,12 +360,12 @@ class Params(object):
|
|||
value = self._getParam(category, name, profile=profile)
|
||||
return self._getAttr(node[1], attr, value)
|
||||
|
||||
def asyncGetStringParamA(self, name, category, attr="value", security_limit=C.NO_SECURITY_LIMIT, profile_key="@NONE@"):
|
||||
def asyncGetStringParamA(self, name, category, attr="value", security_limit=C.NO_SECURITY_LIMIT, profile_key=C.PROF_KEY_NONE):
|
||||
d = self.asyncGetParamA(name, category, attr, security_limit, profile_key)
|
||||
d.addCallback(self.__type_to_string)
|
||||
return d
|
||||
|
||||
def asyncGetParamA(self, name, category, attr="value", security_limit=C.NO_SECURITY_LIMIT, profile_key="@NONE@"):
|
||||
def asyncGetParamA(self, name, category, attr="value", security_limit=C.NO_SECURITY_LIMIT, profile_key=C.PROF_KEY_NONE):
|
||||
"""Helper method to get a specific attribute
|
||||
@param name: name of the parameter
|
||||
@param category: category of the parameter
|
||||
|
|
@ -402,7 +402,7 @@ class Params(object):
|
|||
d = self.storage.getIndParam(category, name, profile)
|
||||
return d.addCallback(lambda value: self._getAttr(node[1], attr, value))
|
||||
|
||||
def _getParam(self, category, name, type_=C.INDIVIDUAL, cache=None, profile="@NONE@"):
|
||||
def _getParam(self, category, name, type_=C.INDIVIDUAL, cache=None, profile=C.PROF_KEY_NONE):
|
||||
"""Return the param, or None if it doesn't exist
|
||||
@param category: param category
|
||||
@param name: param name
|
||||
|
|
@ -416,7 +416,7 @@ class Params(object):
|
|||
return self.params_gen[(category, name)]
|
||||
return None # This general param has the default value
|
||||
assert (type_ == C.INDIVIDUAL)
|
||||
if profile == "@NONE@":
|
||||
if profile == C.PROF_KEY_NONE:
|
||||
raise exceptions.ProfileNotSetError
|
||||
if profile in self.params:
|
||||
cache = self.params[profile] # if profile is in main cache, we use it,
|
||||
|
|
@ -608,10 +608,10 @@ class Params(object):
|
|||
categories.append(cat.getAttribute("name"))
|
||||
return categories
|
||||
|
||||
def setParam(self, name, value, category, security_limit=C.NO_SECURITY_LIMIT, profile_key='@NONE@'):
|
||||
def setParam(self, name, value, category, security_limit=C.NO_SECURITY_LIMIT, profile_key=C.PROF_KEY_NONE):
|
||||
"""Set a parameter, return None if the parameter is not in param xml"""
|
||||
#TODO: use different behaviour depending of the data type (e.g. password encrypted)
|
||||
if profile_key != "@NONE@":
|
||||
if profile_key != C.PROF_KEY_NONE:
|
||||
profile = self.getProfileName(profile_key)
|
||||
if not profile:
|
||||
error(_('Trying to set parameter for an unknown profile'))
|
||||
|
|
@ -638,7 +638,7 @@ class Params(object):
|
|||
return
|
||||
|
||||
assert (node[0] == C.INDIVIDUAL)
|
||||
assert (profile_key != "@NONE@")
|
||||
assert (profile_key != C.PROF_KEY_NONE)
|
||||
|
||||
type_ = node[1].getAttribute("type")
|
||||
if type_ == "button":
|
||||
|
|
|
|||
Loading…
Reference in a new issue