view MoinMoin/script/index/ @ 5046:a9e597a6e012

fix imports in moin index build
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Fri, 28 Aug 2009 12:11:50 +0200
parents 2572688e031a
children e005834bbf85
line wrap: on
line source
# -*- coding: iso-8859-1 -*-
MoinMoin - build xapian search engine's index

@copyright: 2006 MoinMoin:ThomasWaldmann
@license: GNU GPL, see COPYING for details.

from MoinMoin.script import MoinScript

class IndexScript(MoinScript):
This tool allows you to control xapian's index of Moin.

Detailed Instructions:
General syntax: moin [options] index build [build-options]

[options] usually should be:

[build-options] see below:
    0. You must run this script as owner of the wiki files, usually this is the
       web server user.

    1. To add the files from '/files.lst' to the index
       moin ... index build --files /files.lst --mode add

    2. To update the index with the files from '/files.lst'
       moin ... index build --files /files.lst --mode update

    3. To rebuild the index with the files from '/files.lst'
       moin ... index build --files /files.lst --mode rebuild

    def __init__(self, argv, def_values):
        MoinScript.__init__(self, argv, def_values)
            "--files", metavar="FILES", dest="file_list",
            help="filename of file list, e.g. files.lst (one file per line)"
            "--mode", metavar="MODE", dest="mode",
            help="either add (unconditionally add to index), update (update an existing index) or rebuild (remove and add)"

    def mainloop(self):
        # Do we have additional files to index?
        if self.options.file_list:
            self.files = file(self.options.file_list)
            self.files = None

class PluginScript(IndexScript):
    """ Xapian index build script class """

    def command(self):
        from import XapianIndex
        XapianIndex(self.request).indexPages(self.files, self.options.mode)