~ubuntu-branches/ubuntu/natty/moin/natty-updates

« back to all changes in this revision

Viewing changes to MoinMoin/search/__init__.py

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2008-06-22 21:17:13 UTC
  • mfrom: (0.9.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080622211713-fpo2zrq3s5dfecxg
Tags: 1.7.0-3
Simplify /etc/moin/wikilist format: "USER URL" (drop unneeded middle
CONFIG_DIR that was wrongly advertised as DATA_DIR).  Make
moin-mass-migrate handle both formats and warn about deprecation of
the old one.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: iso-8859-1 -*-
 
2
"""
 
3
    MoinMoin - search engine
 
4
 
 
5
    @copyright: 2005 MoinMoin:FlorianFesti,
 
6
                2005 MoinMoin:NirSoffer,
 
7
                2005 MoinMoin:AlexanderSchremmer,
 
8
                2006 MoinMoin:ThomasWaldmann,
 
9
                2006 MoinMoin:FranzPletz
 
10
    @license: GNU GPL, see COPYING for details
 
11
"""
 
12
 
 
13
from MoinMoin import log
 
14
logging = log.getLogger(__name__)
 
15
 
 
16
from MoinMoin.search.queryparser import QueryParser
 
17
from MoinMoin.search.builtin import Search
 
18
 
 
19
def searchPages(request, query, sort='weight', mtime=None, historysearch=None, **kw):
 
20
    """ Search the text of all pages for query.
 
21
 
 
22
    @param request: current request
 
23
    @param query: the expression (string or query objects) we want to search for
 
24
    @keyword sort: sorting of the search results, either 'weight' or 'page_name'
 
25
    @keyword mtime: only items modified since mtime
 
26
    @keyword historysearch: include older revisions of items in search
 
27
    @keyword titlesearch: treat all terms as title searches (passed to qp)
 
28
    @keyword case: do case sensitive search (passed to qp)
 
29
    @keyword regex: treat all terms as regular expression (passed to qp)
 
30
    @rtype: SearchResults instance
 
31
    @return: search results
 
32
    """
 
33
    if isinstance(query, str) or isinstance(query, unicode):
 
34
        query = QueryParser(**kw).parse_query(query)
 
35
    return Search(request, query, sort, mtime=mtime,
 
36
            historysearch=historysearch).run()
 
37