From 74725e61fafcbc1ec5d0e5101020ee0a0d213d96 Mon Sep 17 00:00:00 2001 From: Florent Date: Thu, 8 Nov 2012 15:19:49 +0100 Subject: [PATCH] Allow anonyme login on dlfp (closes #923) --- modules/dlfp/backend.py | 11 ++++++++--- modules/dlfp/browser.py | 5 ++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/modules/dlfp/backend.py b/modules/dlfp/backend.py index 5a855960..fa59a640 100644 --- a/modules/dlfp/backend.py +++ b/modules/dlfp/backend.py @@ -43,8 +43,8 @@ class DLFPBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapContent): VERSION = '0.e' LICENSE = 'AGPLv3+' DESCRIPTION = "Da Linux French Page news website" - CONFIG = BackendConfig(Value('username', label='Username', regexp='.+'), - ValueBackendPassword('password', label='Password'), + CONFIG = BackendConfig(Value('username', label='Username', default=''), + ValueBackendPassword('password', label='Password', default=''), ValueBool('get_news', label='Get newspapers', default=True), ValueBool('get_diaries', label='Get diaries', default=False), ValueBool('get_polls', label='Get polls', default=False), @@ -63,7 +63,12 @@ class DLFPBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapContent): } def create_default_browser(self): - return self.create_browser(self.config['username'].get(), self.config['password'].get()) + username = self.config['username'].get() + if username: + password = self.config['password'].get() + else: + password = None + return self.create_browser(username, password) def deinit(self): # don't need to logout if the browser hasn't been used. diff --git a/modules/dlfp/browser.py b/modules/dlfp/browser.py index 9e55900f..d064c9a6 100644 --- a/modules/dlfp/browser.py +++ b/modules/dlfp/browser.py @@ -195,6 +195,9 @@ class DLFP(BaseBrowser): return None def login(self): + if self.username: + return + # not usefull for the moment #self.location('/', no_login=True) data = {'account[login]': self.username, @@ -207,7 +210,7 @@ class DLFP(BaseBrowser): raise BrowserIncorrectPassword() def is_logged(self): - return (self.page and self.page.is_logged()) + return (self.username is None or (self.page and self.page.is_logged())) def close_session(self): self.openurl('/compte/deconnexion', {})