# HG changeset patch # User Goffi # Date 1448639321 -3600 # Node ID 35426d58471c91d3e2ba902612f62fc5eba0b97d # Parent 0fdd8fe34fbf06b259f8beb16f2932532bc00657 core (memory): stopSession implementation diff -r 0fdd8fe34fbf -r 35426d58471c src/memory/memory.py --- a/src/memory/memory.py Fri Nov 27 16:45:55 2015 +0100 +++ b/src/memory/memory.py Fri Nov 27 16:48:41 2015 +0100 @@ -357,6 +357,20 @@ return self.host.initialised.addCallback(backendInitialised) + def stopSession(self, profile): + """Delete a profile session + + @param profile: %(doc_profile)s + """ + if self.host.isConnected(profile): + log.debug(u"Disconnecting profile because of session stop") + self.host.disconnect(profile) + self.auth_sessions.profileDelUnique(profile) + try: + self._entities_cache[profile] + except KeyError: + log.warning(u"Profile was not in cache") + def _isSessionStarted(self, profile_key): return self.isSessionStarted(self.getProfileName(profile_key)) @@ -374,6 +388,7 @@ @param password (unicode): the SàT profile password @param profile: %(doc_profile)s @return (D): a deferred None in case of success, a failure otherwise. + @raise exceptions.PasswordError: the password does not match """ session_data = self.auth_sessions.profileGetUnique(profile) if not password and session_data: @@ -385,7 +400,7 @@ def check_result(result): if not result: log.warning(u'Authentication failure of profile {}'.format(profile)) - raise exceptions.PasswordError(u"The provided profile password doesn't match.") + raise failure.Failure(exceptions.PasswordError(u"The provided profile password doesn't match.")) if not session_data: # avoid to create two profile sessions when password if specified return self.newAuthSession(password, profile)