Back to index

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

List of all members.

Public Member Functions

def __init__
def xapian_term
def __str__
def negate
def pageFilter
def search
def highlight_re
def xapian_need_postproc
def __unicode__

Public Attributes

 negated
 use_re
 case
 search_re

Static Public Attributes

int costs = 5000

Private Member Functions

def _get_matches

Static Private Attributes

string _tag = 'domain:'
string _field_to_search = 'domain'

Detailed Description

Search for pages belonging to a specific domain 

Definition at line 567 of file expressions.py.


Constructor & Destructor Documentation

def MoinMoin.search.queryparser.expressions.DomainSearch.__init__ (   self,
  pattern,
  use_re = False,
  case = False 
)
Init a domain search

@param pattern: pattern to search for, ascii string or unicode
@param use_re: treat pattern as re of plain text, bool
@param case: do case sensitive search, bool

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

Definition at line 574 of file expressions.py.

00574 
00575     def __init__(self, pattern, use_re=False, case=False):
00576         """ Init a domain search
00577 
00578         @param pattern: pattern to search for, ascii string or unicode
00579         @param use_re: treat pattern as re of plain text, bool
00580         @param case: do case sensitive search, bool
00581         """
00582         # always lowercase and not case-sensitive
00583         super(DomainSearch, self).__init__(pattern.lower(), use_re, case=False)


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 in MoinMoin.search.queryparser.expressions.AndExpression.

Definition at line 156 of file expressions.py.

00156 
00157     def __unicode__(self):
00158         neg = self.negated and '-' or ''
00159         return u'%s%s"%s"' % (neg, self._tag, unicode(self._pattern))
00160 

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

Definition at line 584 of file expressions.py.

00584 
00585     def _get_matches(self, page):
00586         checks = {'underlay': page.isUnderlayPage,
00587                   'standard': page.isStandardPage,
00588                   'system': lambda page=page: wikiutil.isSystemPage(page.request, page.page_name),
00589                  }
00590 
00591         try:
00592             match = checks[self.pattern]()
00593         except KeyError:
00594             match = False
00595 
00596         if match:
00597             return [Match()]
00598         else:
00599             return []
00600 
Return a regular expression of what the term searches for

Used to display the needle in the page.

Reimplemented in MoinMoin.search.queryparser.expressions.CategorySearch, MoinMoin.search.queryparser.expressions.LinkSearch, MoinMoin.search.queryparser.expressions.TextSearch, and MoinMoin.search.queryparser.expressions.AndExpression.

Definition at line 109 of file expressions.py.

00109 
00110     def highlight_re(self):
00111         """ Return a regular expression of what the term searches for
00112 
00113         Used to display the needle in the page.
00114         """
00115         return u''

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 get a page name, and return bool.

The default expression does not have any filter function and
return None. Sub class may define custom filter functions.

Reimplemented in MoinMoin.search.queryparser.expressions.TitleSearch, and MoinMoin.search.queryparser.expressions.AndExpression.

Definition at line 69 of file expressions.py.

00069 
00070     def pageFilter(self):
00071         """ Return a page filtering function
00072 
00073         This function is used to filter page list before we search
00074         it. Return a function that get a page name, and return bool.
00075 
00076         The default expression does not have any filter function and
00077         return None. Sub class may define custom filter functions.
00078         """
00079         return None

def MoinMoin.search.queryparser.expressions.BaseExpression.search (   self,
  page 
) [inherited]
Search a page

Returns a list of Match objects or None if term didn't find
anything (vice versa if negate() was called).  Terms containing
other terms must call this method to aggregate the results.
This Base class returns True (Match()) if not negated.

Reimplemented in MoinMoin.search.queryparser.expressions.OrExpression, and MoinMoin.search.queryparser.expressions.AndExpression.

Definition at line 83 of file expressions.py.

00083 
00084     def search(self, page):
00085         """ Search a page
00086 
00087         Returns a list of Match objects or None if term didn't find
00088         anything (vice versa if negate() was called).  Terms containing
00089         other terms must call this method to aggregate the results.
00090         This Base class returns True (Match()) if not negated.
00091         """
00092         logging.debug("%s searching page %r for (negated = %r) %r" % (self.__class__, page.page_name, self.negated, self._pattern))
00093 
00094         matches = self._get_matches(page)
00095 
00096         # Decide what to do with the results.
00097         if self.negated:
00098             if matches:
00099                 result = None
00100             else:
00101                 result = [Match()] # represents "matched" (but as it was a negative match, we have nothing to show)
00102         else: # not negated
00103             if matches:
00104                 result = matches
00105             else:
00106                 result = None
00107         logging.debug("%s returning %r" % (self.__class__, result))
00108         return result

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented in MoinMoin.search.queryparser.expressions.AndExpression.

Definition at line 153 of file expressions.py.

00153 
00154     def xapian_need_postproc(self):
00155         return self.case

def MoinMoin.search.queryparser.expressions.BaseFieldSearch.xapian_term (   self,
  request,
  connection 
) [inherited]

Reimplemented in MoinMoin.search.queryparser.expressions.CategorySearch.

Definition at line 419 of file expressions.py.

00419 
00420     def xapian_term(self, request, connection):
00421         if self.use_re:
00422             return self._get_query_for_search_re(connection, self._field_to_search)
00423         else:
00424             return connection.query_field(self._field_to_search, self._pattern)
00425 

Here is the call graph for this function:


Member Data Documentation

Reimplemented from MoinMoin.search.queryparser.expressions.BaseFieldSearch.

Definition at line 571 of file expressions.py.

string MoinMoin.search.queryparser.expressions.DomainSearch._tag = 'domain:' [static, private]

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

Definition at line 570 of file expressions.py.

Definition at line 53 of file expressions.py.

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

Definition at line 572 of file expressions.py.

Reimplemented in MoinMoin.search.queryparser.expressions.AndExpression.

Definition at line 51 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: