From: Marek Marecki Date: Sat, 14 Sep 2013 22:27:00 +0000 (+0200) Subject: diaspy.connection.Connection.login() returns Connection() object as well X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=f3b7fd44e18cea43f3634cbc01409065dd75ad53;p=diaspy.git diaspy.connection.Connection.login() returns Connection() object as well as modifying it in-place --- diff --git a/Changelog.markdown b/Changelog.markdown index a1af97a..56322f0 100644 --- a/Changelog.markdown +++ b/Changelog.markdown @@ -31,6 +31,10 @@ up-to-date than manual and if conflicts appear they should follow the order: * __new__: `diaspy.people.User._fetchstream()` method, +* __upd__: `diaspy.connection.Connection.login()` modifies connection object in-place **and** returns it (this allows more fluent API), +* __upd__: `diaspy.connection.Connection.login()` no longer returns status code (if login was unsuccessful it'll raise an exception), +* __upd__: `diaspy.connection.Connection._login()` no longer returns status code (if login was unsuccessful it'll raise an exception), + ---- diff --git a/diaspy/connection.py b/diaspy/connection.py index baec218..50b1d44 100644 --- a/diaspy/connection.py +++ b/diaspy/connection.py @@ -147,7 +147,6 @@ class Connection(): allow_redirects=False) if request.status_code != 302: raise errors.LoginError('{0}: login failed'.format(request.status_code)) - return request.status_code def login(self, remember_me=1): """This function is used to log in to a pod. @@ -158,7 +157,7 @@ class Connection(): self._login_data['user[remember_me]'] = remember_me status = self._login() self._login_data = {} - return status + return self def logout(self): """Logs out from a pod.