Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions
MoinMoin.search.queryparser.expressions.OrExpression Class Reference
Inheritance diagram for MoinMoin.search.queryparser.expressions.OrExpression:
Inheritance graph
[legend]
Collaboration diagram for MoinMoin.search.queryparser.expressions.OrExpression:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def search
def xapian_term
def append
def subterms
def costs
def __unicode__
def pageFilter
def sortByCost
def highlight_re
def xapian_need_postproc
def __str__
def negate

Public Attributes

 negated
 use_re
 case
 search_re

Static Public Attributes

string operator = ' or '
int costs = 0

Private Member Functions

def _filter

Detailed Description

A term connecting several sub terms with a logical OR 

Definition at line 269 of file expressions.py.


Member Function Documentation

Definition at line 62 of file expressions.py.

00062 
00063     def __str__(self):
00064         return unicode(self).encode(config.charset, 'replace')

Reimplemented from MoinMoin.search.queryparser.expressions.BaseExpression.

Definition at line 181 of file expressions.py.

00181 
00182     def __unicode__(self):
00183         result = ''
00184         for t in self._subterms:
00185             result += self.operator + unicode(t)
00186         return u'[' + result[len(self.operator):] + u']'

def MoinMoin.search.queryparser.expressions.OrExpression._filter (   self,
  terms,
  name 
) [private]
A function that returns True if any term filters name 

Reimplemented from MoinMoin.search.queryparser.expressions.AndExpression.

Definition at line 274 of file expressions.py.

00274 
00275     def _filter(self, terms, name):
00276         """ A function that returns True if any term filters name """
00277         result = None
00278         for term in terms:
00279             _filter = term.pageFilter()
00280             t = _filter(name)
00281             if t is True:
00282                 result = True
00283                 break
00284             elif t is False:
00285                 result = False
00286         logging.debug("pageFilter OR returns %r" % result)
00287         return result

def MoinMoin.search.queryparser.expressions.AndExpression.append (   self,
  expression 
) [inherited]
Append another term 

Definition at line 170 of file expressions.py.

00170 
00171     def append(self, expression):
00172         """ Append another term """
00173         self._subterms.append(expression)

Here is the caller graph for this function:

Definition at line 178 of file expressions.py.

00178 
00179     def costs(self):
00180         return sum([t.costs for t in self._subterms])

Return a regular expression of what the term searches for

Used to display the needle in the page.

Reimplemented from MoinMoin.search.queryparser.expressions.BaseExpression.

Definition at line 228 of file expressions.py.

00228 
00229     def highlight_re(self):
00230         result = []
00231         for s in self._subterms:
00232             highlight_re = s.highlight_re()
00233             if highlight_re:
00234                 result.append(highlight_re)
00235 
00236         return u'|'.join(result)

Negate the result of this term 

Definition at line 65 of file expressions.py.

00065 
00066     def negate(self):
00067         """ Negate the result of this term """
00068         self.negated = 1

Return a page filtering function

This function is used to filter page list before we search it.

Return a function that gets a page name, and return bool, or None.

Reimplemented from MoinMoin.search.queryparser.expressions.BaseExpression.

Definition at line 201 of file expressions.py.

00201 
00202     def pageFilter(self):
00203         """ Return a page filtering function
00204 
00205         This function is used to filter page list before we search it.
00206 
00207         Return a function that gets a page name, and return bool, or None.
00208         """
00209         # Sort terms by cost, then get all title searches
00210         self.sortByCost()
00211         terms = [term for term in self._subterms if isinstance(term, TitleSearch)]
00212         if terms:
00213             return lambda name: self._filter(terms, name)

Here is the call graph for this function:

Search page with terms

@param page: the page instance

Reimplemented from MoinMoin.search.queryparser.expressions.AndExpression.

Definition at line 288 of file expressions.py.

00288 
00289     def search(self, page):
00290         """ Search page with terms
00291 
00292         @param page: the page instance
00293         """
00294 
00295         # XXX Do we have any reason to sort here? we are not breaking out
00296         # of the search in any case.
00297         #self.sortByCost()
00298         matches = []
00299         for term in self._subterms:
00300             result = term.search(page)
00301             if result:
00302                 matches.extend(result)
00303         return matches

Here is the caller graph for this function:

Definition at line 214 of file expressions.py.

00214 
00215     def sortByCost(self):
00216         self._subterms.sort(key=lambda t: t.costs)

Here is the caller graph for this function:

Definition at line 174 of file expressions.py.

00174 
00175     def subterms(self):
00176         return self._subterms

Reimplemented from MoinMoin.search.queryparser.expressions.BaseExpression.

Definition at line 237 of file expressions.py.

00237 
00238     def xapian_need_postproc(self):
00239         for term in self._subterms:
00240             if term.xapian_need_postproc():
00241                 return True
00242         return False

def MoinMoin.search.queryparser.expressions.OrExpression.xapian_term (   self,
  request,
  connection 
)

Reimplemented from MoinMoin.search.queryparser.expressions.AndExpression.

Definition at line 304 of file expressions.py.

00304 
00305     def xapian_term(self, request, connection):
00306         # XXX: negated terms managed by _moinSearch?
00307         return Query(OP_OR, [term.xapian_term(request, connection) for term in self._subterms])
00308 


Member Data Documentation

Definition at line 53 of file expressions.py.

Reimplemented from MoinMoin.search.queryparser.expressions.BaseExpression.

Definition at line 168 of file expressions.py.

Reimplemented from MoinMoin.search.queryparser.expressions.AndExpression.

Definition at line 272 of file expressions.py.

Reimplemented in MoinMoin.search.queryparser.expressions.BaseTextFieldSearch.

Definition at line 60 of file expressions.py.

Definition at line 52 of file expressions.py.


The documentation for this class was generated from the following file: