web/facet.py
changeset 9373 d5d9acadb975
parent 9139 5ca6e0ab0227
child 9492 c7fc56eecd1a
equal deleted inserted replaced
9372:e87a808a4c32 9373:d5d9acadb975
   125     baserql = select.as_string(kwargs=rset.args) # before call to prepare_select
   125     baserql = select.as_string(kwargs=rset.args) # before call to prepare_select
   126     prepare_select(select, filtered_variable)
   126     prepare_select(select, filtered_variable)
   127     return filtered_variable, baserql
   127     return filtered_variable, baserql
   128 
   128 
   129 def get_filtered_variable(select, mainvar=None):
   129 def get_filtered_variable(select, mainvar=None):
   130     """drop any limit/offset from select (in-place modification) and return the
   130     """ Return the variable whose name is `mainvar`
   131     variable whose name is `mainvar` or the first variable selected in column 0
   131     or the first variable selected in column 0
   132     """
   132     """
   133     select.set_limit(None)
       
   134     select.set_offset(None)
       
   135     if mainvar is None:
   133     if mainvar is None:
   136         vref = select.selection[0].iget_nodes(nodes.VariableRef).next()
   134         vref = select.selection[0].iget_nodes(nodes.VariableRef).next()
   137         return vref.variable
   135         return vref.variable
   138     return select.defined_vars[mainvar]
   136     return select.defined_vars[mainvar]
   139 
   137