rqlrewrite.py
branchstable
changeset 8296 f23782a2cdee
parent 8264 a4b009ba92ce
child 8452 1ad42383a9ec
equal deleted inserted replaced
8295:302dcb3c6858 8296:f23782a2cdee
   243                 previous = previous or new
   243                 previous = previous or new
   244             else:
   244             else:
   245                 # called to reintroduce snippet due to ambiguity creation,
   245                 # called to reintroduce snippet due to ambiguity creation,
   246                 # so skip snippets which are not introducing this ambiguity
   246                 # so skip snippets which are not introducing this ambiguity
   247                 exists = varexistsmap[varmap]
   247                 exists = varexistsmap[varmap]
   248                 if self.exists_snippet[rqlexpr] is exists:
   248                 if self.exists_snippet.get(rqlexpr) is exists:
   249                     self.insert_snippet(varmap, rqlexpr.snippet_rqlst, exists)
   249                     self.insert_snippet(varmap, rqlexpr.snippet_rqlst, exists)
   250         if varexistsmap is None and not inserted:
   250         if varexistsmap is None and not inserted:
   251             # no rql expression found matching rql solutions. User has no access right
   251             # no rql expression found matching rql solutions. User has no access right
   252             raise Unauthorized() # XXX may also be because of bad constraints in schema definition
   252             raise Unauthorized() # XXX may also be because of bad constraints in schema definition
   253 
   253 
   479                     del variante[key]
   479                     del variante[key]
   480         return variantes
   480         return variantes
   481 
   481 
   482     def _cleanup_inserted(self, node):
   482     def _cleanup_inserted(self, node):
   483         # cleanup inserted variable references
   483         # cleanup inserted variable references
       
   484         removed = set()
   484         for vref in node.iget_nodes(n.VariableRef):
   485         for vref in node.iget_nodes(n.VariableRef):
   485             vref.unregister_reference()
   486             vref.unregister_reference()
   486             if not vref.variable.stinfo['references']:
   487             if not vref.variable.stinfo['references']:
   487                 # no more references, undefine the variable
   488                 # no more references, undefine the variable
   488                 del self.select.defined_vars[vref.name]
   489                 del self.select.defined_vars[vref.name]
       
   490                 removed.add(vref.name)
       
   491         for key, newvar in self.rewritten.items(): # I mean items we alter it
       
   492             if newvar in removed:
       
   493                 del self.rewritten[key]
       
   494 
   489 
   495 
   490     def _may_be_shared_with(self, sniprel, target):
   496     def _may_be_shared_with(self, sniprel, target):
   491         """if the snippet relation can be skipped to use a relation from the
   497         """if the snippet relation can be skipped to use a relation from the
   492         original query, return that relation node
   498         original query, return that relation node
   493         """
   499         """