[connection] Connection.execute touch Session timestamp
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Thu, 27 Jun 2013 11:20:14 +0200
changeset 9089 b4c12d2873f6
parent 9088 04ceb4268b3b
child 9090 e33ff287f082
[connection] Connection.execute touch Session timestamp This allow to keep Session alive while using Connection object only for database access.
server/session.py
--- a/server/session.py	Tue Jun 25 17:42:12 2013 +0200
+++ b/server/session.py	Thu Jun 27 11:20:14 2013 +0200
@@ -431,6 +431,9 @@
         self.vreg = self.repo.vreg
         self._execute = self.repo.querier.execute
 
+        # other session utility
+        self._session_timestamp = session._timestamp
+
         #: connection handling mode
         self.mode = session.default_mode
         #: connection set used to execute queries on sources
@@ -477,6 +480,7 @@
         else:
             self._set_user(session.user)
 
+
     # shared data handling ###################################################
 
     @property
@@ -883,11 +887,13 @@
 
         See :meth:`cubicweb.dbapi.Cursor.execute` documentation.
         """
+        self._session_timestamp.touch()
         if eid_key is not None:
             warn('[3.8] eid_key is deprecated, you can safely remove this argument',
                  DeprecationWarning, stacklevel=2)
         rset = self._execute(self, rql, kwargs, build_descr)
         rset.req = self
+        self._session_timestamp.touch()
         return rset
 
     # resource accessors ######################################################
@@ -1302,7 +1308,6 @@
 
         See :meth:`cubicweb.dbapi.Cursor.execute` documentation.
         """
-        self._timestamp.touch() # update timestamp
         rset = self._cnx.execute(*args, **kwargs)
         rset.req = self
         return rset