From: Matthijs Kooijman Date: Thu, 29 Apr 2010 11:50:30 +0000 (+0200) Subject: mysql_login: Use logger instead of request.log. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=212e4b7e56012b4a04df1f1e9180b9c521aaead1;p=matthijs%2Fprojects%2Fwipi.git mysql_login: Use logger instead of request.log. request.log was removed in Moinmoin 1.9. This also deprecates the verbose setting, which is no longer needed. --- diff --git a/conf/auth/mysql_login.py b/conf/auth/mysql_login.py index 95b3aa6..b34ecf9 100644 --- a/conf/auth/mysql_login.py +++ b/conf/auth/mysql_login.py @@ -10,12 +10,14 @@ import MySQLdb import md5 from MoinMoin import user from MoinMoin.auth import BaseAuth, ContinueLogin +from MoinMoin import log +logging = log.getLogger(__name__) class mysql_login(BaseAuth): logout_possible = True login_inputs = ['username', 'password'] - def __init__(self, name='mysql', dbhost=None, dbuser=None, dbpass=None, dbname=None, dbport=None, verbose=False, hint=None): + def __init__(self, name='mysql', dbhost=None, dbuser=None, dbpass=None, dbname=None, dbport=None, hint=None): """ Authenticate using credentials from a mysql database @@ -23,7 +25,6 @@ class mysql_login(BaseAuth): The hint parameter is a snippet of HTML that is displayed below the login form. """ - self.verbose = verbose self.dbhost = dbhost self.dbuser = dbuser self.dbpass = dbpass @@ -87,8 +88,8 @@ class mysql_login(BaseAuth): import sys import traceback info = sys.exc_info() - request.log("mysql_login: authentication failed due to exception connecting to DB, traceback follows...") - request.log(''.join(traceback.format_exception(*info))) + logging.error("mysql_login: authentication failed due to exception connecting to DB, traceback follows...") + logging.error(''.join(traceback.format_exception(*info))) return False return conn @@ -98,7 +99,7 @@ class mysql_login(BaseAuth): username = kw.get('username') password = kw.get('password') - if self.verbose: request.log("mysql_login: Trying to log in, username=%r " % (username)) + logging.debug("mysql_login: Trying to log in, username=%r " % (username)) # simply continue if something else already logged in # successfully @@ -113,10 +114,10 @@ class mysql_login(BaseAuth): # Login incorrect if (not email): - if self.verbose: request.log("mysql_login: authentication failed for %s" % (username)) + logging.debug("mysql_login: authentication failed for %s" % (username)) return ContinueLogin(user_obj) - if self.verbose: request.log("mysql_login: authenticated %s (email %s)" % (username, email)) + logging.debug("mysql_login: authenticated %s (email %s)" % (username, email)) u = user.User(request, auth_username=username, auth_method=self.name, auth_attribs=('name', 'password', 'email')) u.email = email @@ -128,8 +129,8 @@ class mysql_login(BaseAuth): import sys import traceback info = sys.exc_info() - request.log("mysql_login: authentication failed due to unexpected exception, traceback follows...") - request.log(''.join(traceback.format_exception(*info))) + logging.error("mysql_login: authentication failed due to unexpected exception, traceback follows...") + logging.error(''.join(traceback.format_exception(*info))) return ContinueLogin(user_obj) def login_hint(self, request): diff --git a/conf/farmconfig.py b/conf/farmconfig.py index f12dac6..3ad8251 100644 --- a/conf/farmconfig.py +++ b/conf/farmconfig.py @@ -163,7 +163,6 @@ class FarmConfig(DefaultConfig): from dbsettings import phpbb_dbhost, phpbb_dbuser, phpbb_dbpass, phpbb_dbname phpbb = mysql_login( name = 'phpbb', - verbose = True, dbhost = phpbb_dbhost, dbuser = phpbb_dbuser, dbpass = phpbb_dbpass,