Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes | Private Member Functions
MoinMoin.search.builtin.BaseIndex Class Reference
Inheritance diagram for MoinMoin.search.builtin.BaseIndex:
Inheritance graph
[legend]

List of all members.

Public Member Functions

def __init__
def exists
def mtime
def touch
def search
def update_item
def indexPages
def do_queued_updates
def optimize
def contentfilter

Public Attributes

 request
 main_dir
 update_queue

Private Member Functions

def _main_dir
def _search
def _index_pages
def _indexingRequest

Detailed Description

Represents a search engine index 

Definition at line 95 of file builtin.py.


Constructor & Destructor Documentation

def MoinMoin.search.builtin.BaseIndex.__init__ (   self,
  request 
)
@param request: current request

Definition at line 98 of file builtin.py.

00098 
00099     def __init__(self, request):
00100         """
00101         @param request: current request
00102         """
00103         self.request = request
00104         self.main_dir = self._main_dir()
00105         if not os.path.exists(self.main_dir):
00106             os.makedirs(self.main_dir)
00107         self.update_queue = IndexerQueue(request, self.main_dir, 'indexer-queue')


Member Function Documentation

def MoinMoin.search.builtin.BaseIndex._index_pages (   self,
  request,
  files = None,
  mode = 'update',
  pages = None 
) [private]
Index all pages (and all given files)

This should be called from indexPages only!

@param request: current request
@param files: iterator or list of files to index additionally
@param mode: set the mode of indexing the pages, either 'update' or 'add'
@param pages: list of pages to index, if not given, all pages are indexed

Reimplemented in MoinMoin.search.Xapian.indexing.XapianIndex.

Definition at line 162 of file builtin.py.

00162 
00163     def _index_pages(self, request, files=None, mode='update', pages=None):
00164         """ Index all pages (and all given files)
00165 
00166         This should be called from indexPages only!
00167 
00168         @param request: current request
00169         @param files: iterator or list of files to index additionally
00170         @param mode: set the mode of indexing the pages, either 'update' or 'add'
00171         @param pages: list of pages to index, if not given, all pages are indexed
00172 
00173         """
00174         raise NotImplemented('...')

Here is the caller graph for this function:

def MoinMoin.search.builtin.BaseIndex._indexingRequest (   self,
  request 
) [private]
Return a new request that can be used for index building.

This request uses a security policy that lets the current user
read any page. Without this policy some pages will not render,
which will create broken pagelinks index.

@param request: current request

Definition at line 210 of file builtin.py.

00210 
00211     def _indexingRequest(self, request):
00212         """ Return a new request that can be used for index building.
00213 
00214         This request uses a security policy that lets the current user
00215         read any page. Without this policy some pages will not render,
00216         which will create broken pagelinks index.
00217 
00218         @param request: current request
00219         """
00220         import copy
00221         from MoinMoin.security import Permissions
00222         from MoinMoin.logfile import editlog
00223 
00224         class SecurityPolicy(Permissions):
00225 
00226             def read(self, *args, **kw):
00227                 return True
00228 
00229         r = copy.copy(request)
00230         r.user.may = SecurityPolicy(r.user)
00231         r.editlog = editlog.EditLog(r)
00232         return r
00233 

Here is the caller graph for this function:

Reimplemented in MoinMoin.search.Xapian.indexing.XapianIndex.

Definition at line 108 of file builtin.py.

00108 
00109     def _main_dir(self):
00110         raise NotImplemented('...')

def MoinMoin.search.builtin.BaseIndex._search (   self,
  query 
) [private]
Actually perfom the search

@param query: the search query objects tree

Definition at line 123 of file builtin.py.

00123 
00124     def _search(self, query):
00125         """ Actually perfom the search
00126 
00127         @param query: the search query objects tree
00128         """
00129         raise NotImplemented('...')

Here is the caller graph for this function:

def MoinMoin.search.builtin.BaseIndex.contentfilter (   self,
  filename 
)
Get a filter for content of filename and return unicode content.

@param filename: name of the file

Definition at line 187 of file builtin.py.

00187 
00188     def contentfilter(self, filename):
00189         """ Get a filter for content of filename and return unicode content.
00190 
00191         @param filename: name of the file
00192         """
00193         request = self.request
00194         mt = wikiutil.MimeType(filename=filename)
00195         for modulename in mt.module_name():
00196             try:
00197                 execute = wikiutil.importPlugin(request.cfg, 'filter', modulename)
00198                 break
00199             except wikiutil.PluginMissingError:
00200                 pass
00201             else:
00202                 logging.info("Cannot load filter for mimetype %s" % modulename)
00203         try:
00204             data = execute(self, filename)
00205             logging.debug("Filter %s returned %d characters for file %s" % (modulename, len(data), filename))
00206         except (OSError, IOError), err:
00207             data = ''
00208             logging.warning("Filter %s threw error '%s' for file %s" % (modulename, str(err), filename))
00209         return mt.mime_type(), data

Here is the caller graph for this function:

def MoinMoin.search.builtin.BaseIndex.do_queued_updates (   self,
  amount = -1 
)
Perform updates in the queues

@param request: the current request
@keyword amount: how many updates to perform at once (default: -1 == all)

Reimplemented in MoinMoin.search.Xapian.indexing.XapianIndex.

Definition at line 175 of file builtin.py.

00175 
00176     def do_queued_updates(self, amount=-1):
00177         """ Perform updates in the queues
00178 
00179         @param request: the current request
00180         @keyword amount: how many updates to perform at once (default: -1 == all)
00181         """
00182         raise NotImplemented('...')

Here is the caller graph for this function:

Check if index exists 

Reimplemented in MoinMoin.search.Xapian.indexing.XapianIndex.

Definition at line 111 of file builtin.py.

00111 
00112     def exists(self):
00113         """ Check if index exists """
00114         raise NotImplemented('...')

Here is the caller graph for this function:

def MoinMoin.search.builtin.BaseIndex.indexPages (   self,
  files = None,
  mode = 'update',
  pages = None 
)
Index pages (and files, if given)

@param files: iterator or list of files to index additionally
@param mode: set the mode of indexing the pages, either 'update' or 'add'
@param pages: list of pages to index, if not given, all pages are indexed

Definition at line 149 of file builtin.py.

00149 
00150     def indexPages(self, files=None, mode='update', pages=None):
00151         """ Index pages (and files, if given)
00152 
00153         @param files: iterator or list of files to index additionally
00154         @param mode: set the mode of indexing the pages, either 'update' or 'add'
00155         @param pages: list of pages to index, if not given, all pages are indexed
00156         """
00157         start = time.time()
00158         request = self._indexingRequest(self.request)
00159         self._index_pages(request, files, mode, pages=pages)
00160         logging.info("indexing completed successfully in %0.2f seconds." %
00161                     (time.time() - start))

Here is the call graph for this function:

Modification time of the index 

Reimplemented in MoinMoin.search.Xapian.indexing.XapianIndex.

Definition at line 115 of file builtin.py.

00115 
00116     def mtime(self):
00117         """ Modification time of the index """
00118         raise NotImplemented('...')

Here is the caller graph for this function:

Optimize the index if possible 

Definition at line 183 of file builtin.py.

00183 
00184     def optimize(self):
00185         """ Optimize the index if possible """
00186         raise NotImplemented('...')

def MoinMoin.search.builtin.BaseIndex.search (   self,
  query,
  kw 
)
Search for items in the index

@param query: the search query objects to pass to the index

Definition at line 130 of file builtin.py.

00130 
00131     def search(self, query, **kw):
00132         """ Search for items in the index
00133 
00134         @param query: the search query objects to pass to the index
00135         """
00136         return self._search(query, **kw)

Here is the call graph for this function:

Here is the caller graph for this function:

Touch the index 

Reimplemented in MoinMoin.search.Xapian.indexing.XapianIndex.

Definition at line 119 of file builtin.py.

00119 
00120     def touch(self):
00121         """ Touch the index """
00122         raise NotImplemented('...')

Here is the caller graph for this function:

def MoinMoin.search.builtin.BaseIndex.update_item (   self,
  pagename,
  attachmentname = None,
  revno = None,
  now = True 
)
Update a single item (page or attachment) in the index

@param pagename: the name of the page to update
@param attachmentname: the name of the attachment to update
@param revno: a specific revision number (int) or None (all revs)
@param now: do all updates now (default: True)

Definition at line 137 of file builtin.py.

00137 
00138     def update_item(self, pagename, attachmentname=None, revno=None, now=True):
00139         """ Update a single item (page or attachment) in the index
00140 
00141         @param pagename: the name of the page to update
00142         @param attachmentname: the name of the attachment to update
00143         @param revno: a specific revision number (int) or None (all revs)
00144         @param now: do all updates now (default: True)
00145         """
00146         self.update_queue.put(pagename, attachmentname, revno)
00147         if now:
00148             self.do_queued_updates()

Here is the call graph for this function:


Member Data Documentation

Definition at line 103 of file builtin.py.

Definition at line 102 of file builtin.py.

Definition at line 106 of file builtin.py.


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