equal
deleted
inserted
replaced
1 # copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
1 # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
3 # |
3 # |
4 # This file is part of CubicWeb. |
4 # This file is part of CubicWeb. |
5 # |
5 # |
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
432 vref.unregister_reference() |
432 vref.unregister_reference() |
433 if not vref.variable.stinfo['references']: |
433 if not vref.variable.stinfo['references']: |
434 # no more references, undefine the variable |
434 # no more references, undefine the variable |
435 del self.select.defined_vars[vref.name] |
435 del self.select.defined_vars[vref.name] |
436 |
436 |
437 def _may_be_shared_with(self, sniprel, target, searchedvarname): |
437 def _may_be_shared_with(self, sniprel, target): |
438 """if the snippet relation can be skipped to use a relation from the |
438 """if the snippet relation can be skipped to use a relation from the |
439 original query, return that relation node |
439 original query, return that relation node |
440 """ |
440 """ |
441 rschema = self.schema.rschema(sniprel.r_type) |
441 rschema = self.schema.rschema(sniprel.r_type) |
442 try: |
442 try: |
559 return |
559 return |
560 if isinstance(rhs, n.VariableRef): |
560 if isinstance(rhs, n.VariableRef): |
561 if self.existingvars and not self.keep_var(rhs.name): |
561 if self.existingvars and not self.keep_var(rhs.name): |
562 return |
562 return |
563 if lhs.name in self.revvarmap and rhs.name != 'U': |
563 if lhs.name in self.revvarmap and rhs.name != 'U': |
564 orel = self._may_be_shared_with(node, 'object', lhs.name) |
564 orel = self._may_be_shared_with(node, 'object') |
565 if orel is not None: |
565 if orel is not None: |
566 self._use_orig_term(rhs.name, orel.children[1].children[0]) |
566 self._use_orig_term(rhs.name, orel.children[1].children[0]) |
567 return |
567 return |
568 elif rhs.name in self.revvarmap and lhs.name != 'U': |
568 elif rhs.name in self.revvarmap and lhs.name != 'U': |
569 orel = self._may_be_shared_with(node, 'subject', rhs.name) |
569 orel = self._may_be_shared_with(node, 'subject') |
570 if orel is not None: |
570 if orel is not None: |
571 self._use_orig_term(lhs.name, orel.children[0]) |
571 self._use_orig_term(lhs.name, orel.children[0]) |
572 return |
572 return |
573 rel = n.Relation(node.r_type, node.optional) |
573 rel = n.Relation(node.r_type, node.optional) |
574 for c in node.children: |
574 for c in node.children: |