Back to index

plone3  3.1.7
Functions
AdvancedQuery.eval Namespace Reference

Functions

def _eval
def eval

Function Documentation

def AdvancedQuery.eval._eval (   query,
  cat 
) [private]
evaluate *query* in the context of *cat* (a 'Products.ZCatalog.Catalog.Catalog').

Definition at line 14 of file eval.py.

00014 
00015 def _eval(query, cat):
00016   '''evaluate *query* in the context of *cat* (a 'Products.ZCatalog.Catalog.Catalog').'''
00017   rs = query._eval(_QueryContext(cat))
00018   if isinstance(rs, ISearch):
00019     if hasattr(rs, 'asSet'): rs = rs.asSet()
00020     elif isinstance(rs, IBTree): rs = rs.getTree()
00021     else: hits = tuple(rs); rs = IISet(); rs.__setstate__((hits,))
00022   return rs

Here is the caller graph for this function:

def AdvancedQuery.eval.eval (   catalog,
  query,
  sortSpecs = (),
  withSortValues = _notPassed 
)
evaluate *query* for *catalog*; sort according to *sortSpecs*.

*sortSpecs* is a sequence of sort specifications.

A sort spec is either a ranking spec, an index name or a pair
index name + sort direction ('asc/desc').

If *withSortValues* is not passed, it is set to 'True' when *sortSpecs*
contains a ranking spec; otherwise, it is set to 'False'.

If *withSortValues*, the catalog brains 'data_record_score_' is
abused to communicate the sort value (a tuple with one
component per sort spec). 'data_record_normalized_score_' is
set to 'None' in this case.

Definition at line 23 of file eval.py.

00023 
00024 def eval(catalog, query, sortSpecs=(), withSortValues=_notPassed):
00025   '''evaluate *query* for *catalog*; sort according to *sortSpecs*.
00026 
00027   *sortSpecs* is a sequence of sort specifications.
00028   
00029   A sort spec is either a ranking spec, an index name or a pair
00030   index name + sort direction ('asc/desc').
00031 
00032   If *withSortValues* is not passed, it is set to 'True' when *sortSpecs*
00033   contains a ranking spec; otherwise, it is set to 'False'.
00034 
00035   If *withSortValues*, the catalog brains 'data_record_score_' is
00036   abused to communicate the sort value (a tuple with one
00037   component per sort spec). 'data_record_normalized_score_' is
00038   set to 'None' in this case.
00039   '''
00040   cat = catalog._catalog
00041   rs = _eval(query, cat)
00042   if not rs: return LazyCat(())
00043   sortSpecs, withSortValues = _normSortSpecs(sortSpecs, withSortValues, cat)
00044   if sortSpecs or withSortValues: rs = _sort(rs, sortSpecs, withSortValues)
00045   if hasattr(rs, 'keys'): rs= rs.keys() # a TreeSet does not have '__getitem__'
00046   return LazyMap(cat.__getitem__, rs)

Here is the call graph for this function:

Here is the caller graph for this function: