commit ed4aafe7fc88ff197661863760f71fcc9ebc00ed
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Thu Mar 3 12:46:07 2016 +0100
Override the login method from OpenIdBaseClient to avoid un-necessary calls
With this override we only actually login when we are not already logged
in.
pkgdb2client/__init__.py | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/pkgdb2client/__init__.py b/pkgdb2client/__init__.py
index de81ae3..989a6af 100644
--- a/pkgdb2client/__init__.py
+++ b/pkgdb2client/__init__.py
@@ -131,9 +131,16 @@ class PkgDB(OpenIdBaseClient):
@property
def is_logged_in(self):
''' Return whether the user if logged in or not. '''
- response = self.session.get(self.base_url + '/login/')
+ response = self._session.get(self.base_url + '/login/')
return "logged in as" in response.text
+ def login(self, username, password, otp=None):
+ ''' Calls the login method from OpenIdBaseClient if there is a need
+ for it.
+ '''
+ if not self.is_logged_in:
+ super(PkgDB, self).login(username, password, otp=None)
+
def call_api(self, path, params=None, data=None):
''' call the API.
Show replies by date