diff src/memory/params.py @ 916:1a759096ccbd

core: use of Const for profile_key + replaced '@DEFAULT@' default profile_key by '@NONE@'
author Goffi <goffi@goffi.org>
date Fri, 21 Mar 2014 16:27:09 +0100
parents 1a3ba959f0ab
children fc7e0828b18e
line wrap: on
line diff
--- a/src/memory/params.py	Fri Mar 21 16:19:46 2014 +0100
+++ b/src/memory/params.py	Fri Mar 21 16:27:09 2014 +0100
@@ -176,7 +176,7 @@
                     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 @@
             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 @@
             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 @@
             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 @@
                 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 @@
                 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 @@
             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":