[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()).
--- 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):