diff src/memory/memory.py @ 1263:cfd636203e8f frontends_multi_profiles

core: misc improvments: - added some constants for message types and presence - removed profile authentification specific methods in favor of a more generic "validated" key
author Goffi <goffi@goffi.org>
date Wed, 10 Dec 2014 18:36:11 +0100
parents c585df65828a
children faa1129559b8
line wrap: on
line diff
--- a/src/memory/memory.py	Wed Dec 10 18:32:33 2014 +0100
+++ b/src/memory/memory.py	Wed Dec 10 18:36:11 2014 +0100
@@ -332,8 +332,11 @@
 
     def getProfileName(self, profile_key, return_profile_keys=False):
         """Return name of profile from keyword
+
         @param profile_key: can be the profile name or a keywork (like @DEFAULT@)
-        @return: profile name or None if it doesn't exist"""
+        @param return_profile_keys: if True, return unmanaged profile keys (like "@ALL@"). This keys must be managed by the caller
+        @return: requested profile name or emptry string if it doesn't exist
+        """
         return self.params.getProfileName(profile_key, return_profile_keys)
 
     def asyncCreateProfile(self, name, password=''):
@@ -342,6 +345,10 @@
         @param password: profile password
         @return: Deferred
         """
+        if not name:
+            raise ValueError("Empty profile name")
+        if name[0] == '@':
+            raise ValueError("A profile name can't start with a '@'")
         personal_key = BlockCipher.getRandomKey(base64=True)  # generated once for all and saved in a PersistentDict
         self.auth_sessions.newSession({C.MEMORY_CRYPTO_KEY: personal_key}, profile=name)  # will be encrypted by setParam
         d = self.params.asyncCreateProfile(name)
@@ -579,7 +586,7 @@
             try:
                 del self._entities_cache[profile][entity]
             except KeyError:
-                log.debug("Can't delete entity [%s]: not in cache" % entity.full())
+                log.warning(_("Can't delete entity [{}]: not in cache").format(entity.full()))
 
     def encryptValue(self, value, profile):
         """Encrypt a value for the given profile. The personal key must be loaded