core: use of Const for profile_key + replaced '@DEFAULT@' default profile_key by '@NONE@'

This commit is contained in:
Goffi 2014-03-21 16:27:09 +01:00
commit 005ec59a8a
25 changed files with 123 additions and 101 deletions

View file

@ -241,14 +241,14 @@ class Memory(object):
"""
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 @@ class Memory(object):
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 @@ class Memory(object):
"""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 @@ class Memory(object):
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 @@ class Memory(object):
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):