web/facet.py
changeset 7953 a37531c8a4a6
parent 7943 ad0581296e2c
parent 7944 1faa8edb5ae3
child 8029 805d4e121b65
equal deleted inserted replaced
7951:b7c825b00f64 7953:a37531c8a4a6
    88 
    88 
    89 
    89 
    90 ## rqlst manipulation functions used by facets ################################
    90 ## rqlst manipulation functions used by facets ################################
    91 
    91 
    92 def init_facets(rset, select, mainvar=None):
    92 def init_facets(rset, select, mainvar=None):
       
    93     """Alters in place the <select> for filtering and returns related data.
       
    94 
       
    95     Calls :func:`prepare_select` to prepare the syntaxtree for selection and
       
    96     :func:`get_filtered_variable` that selects the variable to be filtered and
       
    97     drops several parts of the select tree. See each function docstring for
       
    98     details.
       
    99 
       
   100     :param rset: ResultSet we init facet for.
       
   101     :type rset: :class:`~cubicweb.rset.ResultSet`
       
   102 
       
   103     :param select: Select statement to be *altered* to support filtering.
       
   104     :type select:   :class:`~rql.stmts.Select` from the ``rset`` parameters.
       
   105 
       
   106     :param mainvar: Name of the variable we want to filter with facets.
       
   107     :type mainvar:  string
       
   108 
       
   109     :rtype: (filtered_variable, baserql) tuple.
       
   110     :return filtered_variable:  A rql class:`~rql.node.VariableRef`
       
   111                                 instance as returned by
       
   112                                 :func:`get_filtered_variable`.
       
   113 
       
   114     :return baserql: A string containing the rql before
       
   115                      :func:`prepare_select` but after
       
   116                      :func:`get_filtered_variable`.
       
   117     """
    93     rset.req.vreg.rqlhelper.annotate(select)
   118     rset.req.vreg.rqlhelper.annotate(select)
    94     filtered_variable = get_filtered_variable(select, mainvar)
   119     filtered_variable = get_filtered_variable(select, mainvar)
    95     baserql = select.as_string(kwargs=rset.args) # before call to prepare_select
   120     baserql = select.as_string(kwargs=rset.args) # before call to prepare_select
    96     prepare_select(select, filtered_variable)
   121     prepare_select(select, filtered_variable)
    97     return filtered_variable, baserql
   122     return filtered_variable, baserql