retrieve session data in a single query
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 03 Jun 2016 17:59:49 +0200
changeset 11625 b23d60a9ea84
parent 11624 e74bd3130d99
child 11626 0cf2972d2011
retrieve session data in a single query instead of two (one for the session object, the other for its cwsessiondata attribute).
pyramid_cubicweb/session.py
--- a/pyramid_cubicweb/session.py	Tue Jun 28 09:07:12 2016 +0200
+++ b/pyramid_cubicweb/session.py	Fri Jun 03 17:59:49 2016 +0200
@@ -96,8 +96,9 @@
                 return
 
             with self.repo.internal_cnx() as cnx:
-                session = cnx.find('CWSession', eid=self.sessioneid).one()
-                value = session.cwsessiondata
+                value_rset = cnx.execute('Any D WHERE X eid %(x)s, X cwsessiondata D',
+                                         {'x': self.sessioneid})
+                value = value_rset[0][0]
                 if value:
                     # Use directly dict.update to avoir _set_accessed to be
                     # recursively called