[web/sessions] reduce repoapi usage where possible
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Tue, 10 Jun 2014 14:44:36 +0200
changeset 10358 d551d0a162d5
parent 10357 59a79300f213
child 10359 8e4ba1028f55
[web/sessions] reduce repoapi usage where possible Using session.new_cnx() should be the new preferred way. Related to #3837233.
web/views/sessions.py
--- a/web/views/sessions.py	Tue Jun 10 18:17:07 2014 +0200
+++ b/web/views/sessions.py	Tue Jun 10 14:44:36 2014 +0200
@@ -1,4 +1,4 @@
-# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of CubicWeb.
@@ -27,7 +27,6 @@
                       BadConnectionId)
 from cubicweb.web import InvalidSession, Redirect
 from cubicweb.web.application import AbstractSessionManager
-from cubicweb import repoapi
 
 
 class InMemoryRepositorySessionManager(AbstractSessionManager):
@@ -96,8 +95,7 @@
         # XXX should properly detect missing permission / non writeable source
         # and avoid "except (RepositoryError, Unauthorized)" below
         try:
-            cnx = repoapi.Connection(session)
-            with cnx:
+            with session.new_cnx() as cnx:
                 cnx.execute('SET X last_login_time NOW WHERE X eid %(x)s',
                            {'x' : session.user.eid})
                 cnx.commit()