Mercurial > libervia-backend
diff src/memory/memory.py @ 894:57c32d8ec847
core (memory): asyncDeleteProfile can force the deletion of a profile, even if it's connected (when called from the backend only)
author | souliane <souliane@mailoo.org> |
---|---|
date | Mon, 03 Mar 2014 15:37:49 +0100 |
parents | 308a96bc7c1b |
children | fab49a1d5ea2 |
line wrap: on
line diff
--- a/src/memory/memory.py Mon Mar 03 09:59:10 2014 +0100 +++ b/src/memory/memory.py Mon Mar 03 15:37:49 2014 +0100 @@ -228,15 +228,17 @@ return defer.fail(Failure(exceptions.CancelError)) return self.storage.createProfile(profile) - def asyncDeleteProfile(self, profile): + def asyncDeleteProfile(self, profile, force=False): """Delete an existing profile @param profile: name of the profile + @param force: force the deletion even if the profile is connected. + To be used for direct calls only (not through the bridge). @return: a Deferred instance """ if not self.storage.hasProfile(profile): info(_('Trying to delete an unknown profile')) return defer.fail(Failure(exceptions.ProfileUnknownError)) - if self.host.isConnected(profile): + if not force and self.host.isConnected(profile): info(_("Trying to delete a connected profile")) return defer.fail(Failure(exceptions.ConnectedProfileError)) return self.storage.deleteProfile(profile) @@ -882,10 +884,14 @@ """ return self.params.asyncCreateProfile(name) - def asyncDeleteProfile(self, name): + def asyncDeleteProfile(self, name, force=False): """Delete an existing profile - @param name: Name of the profile""" - return self.params.asyncDeleteProfile(name) + @param name: Name of the profile + @param force: force the deletion even if the profile is connected. + To be used for direct calls only (not through the bridge). + @return: a Deferred instance + """ + 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@"