[connection] pass a Connection object to RQLRewriter
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Thu, 27 Jun 2013 11:20:46 +0200
changeset 9090 e33ff287f082
parent 9089 b4c12d2873f6
child 9091 4a39f3f1f1d9
[connection] pass a Connection object to RQLRewriter RQLRewriter can now directly use a Connection object. No need for specific handling session side.
server/session.py
--- a/server/session.py	Thu Jun 27 11:20:14 2013 +0200
+++ b/server/session.py	Thu Jun 27 11:20:46 2013 +0200
@@ -418,7 +418,7 @@
 
     is_request = False
 
-    def __init__(self, cnxid, session, rewriter):
+    def __init__(self, cnxid, session):
         # using super(Connection, self) confuse some test hack
         RequestSessionBase.__init__(self, session.vreg)
         #: connection unique id
@@ -472,7 +472,7 @@
             self.undo_actions = config['undo-enabled']
 
         # RQLRewriter are not thread safe
-        self._rewriter = rewriter
+        self._rewriter = RQLRewriter(self)
 
         # other session utility
         if session.user.login == '__internal_manager__':
@@ -518,6 +518,7 @@
         self.commit_state = None
         self.pruned_hooks_cache = {}
         self.local_perm_cache.clear()
+        self.rewriter = RQLRewriter(self)
 
     # Connection Set Management ###############################################
     @property
@@ -1121,8 +1122,7 @@
                     raise SessionClosedError('try to access connections set on a closed session %s' % self.id)
                 cnx = self._cnxs[cnxid]
             except KeyError:
-                rewriter = RQLRewriter(self)
-                cnx = Connection(cnxid, self, rewriter)
+                cnx = Connection(cnxid, self)
                 self._cnxs[cnxid] = cnx
         return cnx
 
@@ -1349,7 +1349,6 @@
 
     def _clear_cnx_storage(self, cnx):
         cnx.clear()
-        cnx._rewriter = RQLRewriter(self)
 
     def commit(self, free_cnxset=True, reset_pool=None):
         """commit the current session's transaction"""