[ftirank] when ordered by fti rank, we don't want page navigation. Anyway, sorted nav component shouldn't consider has_text relation.
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 08 Jul 2010 15:36:33 +0200
changeset 5944 b962dff47c36
parent 5943 f1abba8ccc01
child 5946 9cbde75fefe8
[ftirank] when ordered by fti rank, we don't want page navigation. Anyway, sorted nav component shouldn't consider has_text relation.
selectors.py
web/views/navigation.py
--- a/selectors.py	Thu Jul 08 15:35:29 2010 +0200
+++ b/selectors.py	Thu Jul 08 15:36:33 2010 +0200
@@ -202,6 +202,7 @@
 from logilab.common.interface import implements as implements_iface
 
 from yams import BASE_TYPES
+from rql.nodes import Function
 
 from cubicweb import (Unauthorized, NoSelectableObject, NotAnEntity,
                       CW_EVENT_MANAGER, role)
@@ -588,12 +589,17 @@
 @lltrace
 def sorted_rset(cls, req, rset=None, **kwargs):
     """Return 1 for sorted result set (e.g. from an RQL query containing an
-    :ref:ORDERBY clause.
+    :ref:ORDERBY clause), with exception that it will return 0 if the rset is
+    'ORDERBY FTIRANK(VAR)' (eg sorted by rank value of the has_text index).
     """
     if rset is None:
         return 0
-    rqlst = rset.syntax_tree()
-    if len(rqlst.children) > 1 or not rqlst.children[0].orderby:
+    selects = rset.syntax_tree().children
+    if (len(selects) > 1 or
+        not selects[0].orderby or
+        (isinstance(selects[0].orderby[0].term, Function) and
+         selects[0].orderby[0].term.name == 'FTIRANK')
+        ):
         return 0
     return 2
 
--- a/web/views/navigation.py	Thu Jul 08 15:35:29 2010 +0200
+++ b/web/views/navigation.py	Thu Jul 08 15:36:33 2010 +0200
@@ -132,7 +132,7 @@
                 if rel is None:
                     continue
                 attrname = rel.r_type
-                if attrname == 'is':
+                if attrname in ('is', 'has_text'):
                     continue
                 if not rschema(attrname).final:
                     col = var.selected_index()