[server.querier] remove useless attribute Querier._planner
authorNicolas Chauvat <nicolas.chauvat@logilab.fr>
Wed, 19 Feb 2020 19:49:01 +0100
changeset 12888 24a20d2b8c84
parent 12887 11953d585a55
child 12889 bbf3e56b43fe
[server.querier] remove useless attribute Querier._planner
cubicweb/server/querier.py
cubicweb/server/ssplanner.py
--- a/cubicweb/server/querier.py	Wed Mar 13 11:02:39 2019 +0100
+++ b/cubicweb/server/querier.py	Wed Feb 19 19:49:01 2020 +0100
@@ -38,7 +38,7 @@
 from cubicweb.misc.source_highlight import highlight_terminal
 from cubicweb.server.rqlannotation import RQLAnnotator, set_qdata
 from cubicweb.server.ssplanner import (READ_ONLY_RTYPES, add_types_restriction,
-                                       SSPlanner)
+                                       prepare_plan)
 from cubicweb.server.edition import EditedEntity
 from cubicweb.statsd_logger import statsd_timeit, statsd_c
 
@@ -473,8 +473,6 @@
     def set_schema(self, schema):
         self.schema = schema
         self.clear_caches()
-        # rql planner
-        self._planner = SSPlanner(schema, self._repo.vreg.rqlhelper)
 
     def clear_caches(self, eids=None, etypes=None):
         if eids is None:
@@ -548,7 +546,7 @@
         plan = self.plan_factory(rqlst, args, cnx)
         plan.cache_key = cachekey
         plan.rql_query_tracing_token = str(uuid.uuid4())
-        self._planner.build_plan(plan)
+        prepare_plan(plan, self.schema, self._repo.vreg.rqlhelper)
 
         query_debug_informations = {
             "rql": rql,
--- a/cubicweb/server/ssplanner.py	Wed Mar 13 11:02:39 2019 +0100
+++ b/cubicweb/server/ssplanner.py	Wed Feb 19 19:49:01 2020 +0100
@@ -307,6 +307,11 @@
         return self.build_select_plan(plan, union)
 
 
+def prepare_plan(plan, schema, rqlhelper):
+    """Add steps to a plan to prepare it for execution"""
+    return SSPlanner(schema, rqlhelper).build_plan(plan)
+
+
 # execution steps and helper functions ########################################
 
 class Step(object):