From f3b7fd44e18cea43f3634cbc01409065dd75ad53 Mon Sep 17 00:00:00 2001 From: Marek Marecki Date: Sun, 15 Sep 2013 00:27:00 +0200 Subject: [PATCH] diaspy.connection.Connection.login() returns Connection() object as well as modifying it in-place --- Changelog.markdown | 4 ++++ diaspy/connection.py | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) 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. -- 2.25.1