[server.querier] remove useless indirections ExecutionPlan.{syssource,rqlhelper,schema}
authorNicolas Chauvat <nicolas.chauvat@logilab.fr>
Wed, 13 Mar 2019 10:40:05 +0100
changeset 12886 fa565be41647
parent 12885 194e9ae964ed
child 12887 11953d585a55
[server.querier] remove useless indirections ExecutionPlan.{syssource,rqlhelper,schema} Simpler is better.
cubicweb/server/querier.py
--- a/cubicweb/server/querier.py	Wed Mar 13 10:26:15 2019 +0100
+++ b/cubicweb/server/querier.py	Wed Mar 13 10:40:05 2019 +0100
@@ -160,14 +160,9 @@
         self.args = args or {}
         # cnx executing the query
         self.cnx = cnx
-        # quick reference to the system source
-        self.syssource = cnx.repo.system_source
         # execution steps
         self.steps = []
-        # various resource accesors
         self.querier = querier
-        self.schema = querier.schema
-        self.rqlhelper = cnx.vreg.rqlhelper
         # tracing token for debugging
         self.rql_query_tracing_token = None
 
@@ -176,7 +171,7 @@
         self.steps.append(step)
 
     def sqlexec(self, sql, args=None):
-        return self.syssource.sqlexec(self.cnx, sql, args)
+        return self.cnx.repo.system_source.sqlexec(self.cnx, sql, args)
 
     def execute(self):
         """execute a plan and return resulting rows"""
@@ -215,9 +210,9 @@
         else:
             noinvariant = ()
         if cached is None:
-            self.rqlhelper.simplify(union)
+            self.cnx.vreg.rqlhelper.simplify(union)
             self.querier.rqlannotator.annotate(union)
-            set_qdata(self.schema.rschema, union, noinvariant)
+            set_qdata(self.querier.schema.rschema, union, noinvariant)
         if union.has_text_query:
             self.cache_key = None
 
@@ -313,8 +308,8 @@
             for sol in solutions:
                 sol[newvarname] = nvartype
         select.clean_solutions(solutions)
-        add_types_restriction(self.schema, select)
-        self.rqlhelper.annotate(rqlst)
+        add_types_restriction(self.querier.schema, select)
+        self.cnx.vreg.rqlhelper.annotate(rqlst)
         self.preprocess(rqlst, security=False)
         return rqlst
 
@@ -344,7 +339,7 @@
     def add_relation_def(self, rdef):
         """add an relation definition to build"""
         edef, rtype, value = rdef
-        if self.schema[rtype].rule:
+        if self.querier.schema[rtype].rule:
             raise QueryError("'%s' is a computed relation" % rtype)
         self.r_defs.add(rdef)
         if not isinstance(edef, int):