diff src/memory/memory.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 ed9841e6d84a
line wrap: on
line diff
--- a/src/memory/memory.py	Fri Mar 21 16:19:46 2014 +0100
+++ b/src/memory/memory.py	Fri Mar 21 16:27:09 2014 +0100
@@ -241,14 +241,14 @@
         """
         return self.params.asyncDeleteProfile(name, force)
 
-    def addToHistory(self, from_jid, to_jid, message, type_='chat', extra=None, timestamp=None, profile="@NONE@"):
-        assert profile != "@NONE@"
+    def addToHistory(self, from_jid, to_jid, message, type_='chat', extra=None, timestamp=None, profile=C.PROF_KEY_NONE):
+        assert profile != C.PROF_KEY_NONE
         if extra is None:
             extra = {}
         return self.storage.addToHistory(from_jid, to_jid, message, type_, extra, timestamp, profile)
 
-    def getHistory(self, from_jid, to_jid, limit=0, between=True, profile="@NONE@"):
-        assert profile != "@NONE@"
+    def getHistory(self, from_jid, to_jid, limit=0, between=True, profile=C.PROF_KEY_NONE):
+        assert profile != C.PROF_KEY_NONE
         return self.storage.getHistory(jid.JID(from_jid), jid.JID(to_jid), limit, between, profile)
 
     def addServerFeature(self, feature, jid_, profile):
@@ -319,7 +319,7 @@
             entities.update(set_)
         return entities
 
-    def hasServerFeature(self, feature, jid_=None, profile_key="@NONE@"):
+    def hasServerFeature(self, feature, jid_=None, profile_key=C.PROF_KEY_NONE):
         """Tell if the specified server has the required feature
         @param feature: requested feature
         @param jid_: the jid of the target server (None for profile's server)
@@ -387,7 +387,7 @@
         """Set a misc data for an entity
         @param entity_jid: JID of the entity, or '@ALL@' to update all entities)
         @param key: key to set (eg: "type")
-        @param value: value for this key (eg: "chatroom"), or '@NONE@' to delete
+        @param value: value for this key (eg: "chatroom"), or C.PROF_KEY_NONE to delete
         @param profile_key: %(doc_profile_key)s
         """
         profile = self.getProfileName(profile_key)
@@ -403,7 +403,7 @@
             entities_map = {entity: self.entitiesCache[profile][entity]}
         for entity in entities_map:
             entity_map = entities_map[entity]
-            if value == "@NONE@" and key in entity_map:
+            if value == C.PROF_KEY_NONE and key in entity_map:
                 del entity_map[key]
             else:
                 entity_map[key] = value
@@ -473,31 +473,31 @@
 
         return self.subscriptions[profile]
 
-    def getStringParamA(self, name, category, attr="value", profile_key='@NONE@'):
+    def getStringParamA(self, name, category, attr="value", profile_key=C.PROF_KEY_NONE):
         return self.params.getStringParamA(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):
         return self.params.getParamA(name, category, attr, profile_key)
 
-    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):
         return self.params.asyncGetParamA(name, category, attr, security_limit, profile_key)
 
-    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):
         return self.params.asyncGetStringParamA(name, category, attr, security_limit, profile_key)
 
-    def getParamsUI(self, security_limit=C.NO_SECURITY_LIMIT, app='', profile_key='@NONE@'):
+    def getParamsUI(self, security_limit=C.NO_SECURITY_LIMIT, app='', profile_key=C.PROF_KEY_NONE):
         return self.params.getParamsUI(security_limit, app, profile_key)
 
-    def getParams(self, security_limit=C.NO_SECURITY_LIMIT, app='', profile_key='@NONE@'):
+    def getParams(self, security_limit=C.NO_SECURITY_LIMIT, app='', profile_key=C.PROF_KEY_NONE):
         return self.params.getParams(security_limit, app, profile_key)
 
-    def getParamsForCategory(self, category, security_limit=C.NO_SECURITY_LIMIT, app='', profile_key='@NONE@'):
+    def getParamsForCategory(self, category, security_limit=C.NO_SECURITY_LIMIT, app='', profile_key=C.PROF_KEY_NONE):
         return self.params.getParamsForCategory(category, security_limit, app, profile_key)
 
     def getParamsCategories(self):
         return self.params.getParamsCategories()
 
-    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):
         return self.params.setParam(name, value, category, security_limit, profile_key)
 
     def updateParams(self, xml):