# HG changeset patch # User Denis Laxalde # Date 1509352132 -3600 # Node ID 5c066dc7307b04dd2d35f72191293d2639915b8a # Parent 79d243a2f0c53939d88d70000cb0c94e175bb0f4 [pyramid] Get rid of a bare "except" in UpdateLoginTimeAuthenticationPolicy Also refactor a bit the method to restrict the try/except block to the code for which we actually want to catch an exception (i.e. the cnx.execute() + cnx.commit()). diff -r 79d243a2f0c5 -r 5c066dc7307b cubicweb/pyramid/auth.py --- a/cubicweb/pyramid/auth.py Mon Oct 30 09:25:22 2017 +0100 +++ b/cubicweb/pyramid/auth.py Mon Oct 30 09:28:52 2017 +0100 @@ -121,16 +121,16 @@ return () def remember(self, request, principal, **kw): - try: - repo = request.registry['cubicweb.repository'] - with repo.internal_cnx() as cnx: + repo = request.registry['cubicweb.repository'] + with repo.internal_cnx() as cnx: + try: cnx.execute( "SET U last_login_time %(now)s WHERE U eid %(user)s", { 'now': datetime.datetime.now(), 'user': principal}) cnx.commit() - except: - log.exception("Failed to update last_login_time") + except Exception: + log.exception("Failed to update last_login_time") return () def forget(self, request):