Mercurial > moin > 1.9
changeset 983:ef39854bac93
merged xapian branch
author | Thomas Waldmann <tw AT waldmann-edv DOT de> |
---|---|
date | Mon, 17 Jul 2006 13:27:35 +0200 |
parents | 11d094495f53 (current diff) 541271bb8a56 (diff) |
children | 311492a91530 |
files | |
diffstat | 4 files changed, 32 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/MoinMoin/macro/SystemInfo.py Mon Jul 17 13:25:37 2006 +0200 +++ b/MoinMoin/macro/SystemInfo.py Mon Jul 17 13:27:35 2006 +0200 @@ -112,7 +112,9 @@ ', '.join(wikiutil.wikiPlugins('parser', Macro.cfg)) or nonestr) state = (_('Disabled'), _('Enabled')) - row(_('Xapian search'), state[request.cfg.xapian_search]) + from MoinMoin.search.builtin import Search + row(_('Xapian search'), '%s, %sactive' % (state[request.cfg.xapian_search], + not Search._xapianIndex(request) and 'not ' or '')) row(_('Active threads'), t_count or 'N/A') buf.write(u'</dl>')
--- a/MoinMoin/search/Xapian.py Mon Jul 17 13:25:37 2006 +0200 +++ b/MoinMoin/search/Xapian.py Mon Jul 17 13:27:35 2006 +0200 @@ -188,6 +188,10 @@ else: return os.path.join(self.request.cfg.cache_dir, 'xapian') + def exists(self): + """ Check if the Xapian index exists """ + return BaseIndex.exists(self) and os.listdir(self.dir) + def _search(self, query): """ read lock must be acquired """ while True: @@ -238,12 +242,6 @@ """ fs_rootpage = 'FS' # XXX FS hardcoded - # rebuilding the DB: delete it and add everything - if mode == 'rebuild': - for f in os.listdir(self.dir): - os.unlink(f) - mode = 'add' - try: wikiname = request.cfg.interwikiname or 'Self' itemid = "%s:%s" % (wikiname, os.path.join(fs_rootpage, filename)) @@ -440,6 +438,13 @@ When called in a new thread, lock is acquired before the call, and this method must release it when it finishes or fails. """ + + # rebuilding the DB: delete it and add everything + if mode == 'rebuild': + for f in os.listdir(self.dir): + os.unlink(os.path.join(self.dir, f)) + mode = 'add' + try: writer = xapidx.Index(self.dir, True) writer.configure(self.prefixMap, self.indexValueMap)
--- a/MoinMoin/search/builtin.py Mon Jul 17 13:25:37 2006 +0200 +++ b/MoinMoin/search/builtin.py Mon Jul 17 13:27:35 2006 +0200 @@ -373,6 +373,18 @@ # ---------------------------------------------------------------- # Private! + def _xapianIndex(request): + try: + from MoinMoin.search.Xapian import Index + index = Index(request) + except ImportError: + index = None + + if index and index.exists(): + return index + + _xapianIndex = staticmethod(_xapianIndex) + def _xapianSearch(self): """ Search using Xapian @@ -380,13 +392,8 @@ return moin search in those pages. """ pages = None - try: - from MoinMoin.search.Xapian import Index - index = Index(self.request) - except ImportError: - index = None - - if index and index.exists(): #and self.query.xapian_wanted(): + index = self._xapianIndex(self.request) + if index: #and self.query.xapian_wanted(): self.request.clock.start('_xapianSearch') try: from MoinMoin.support import xapwrap
--- a/docs/CHANGES.fpletz Mon Jul 17 13:25:37 2006 +0200 +++ b/docs/CHANGES.fpletz Mon Jul 17 13:27:35 2006 +0200 @@ -149,3 +149,7 @@ * Comment read_lock code from BaseIndex (should not be needed) * Support complete rebuild of the database (delete and add) +2006-07-17 + * SystemInfo macro now also shows if xapian is being used (index + available) and more graceful fallback to moinSearch +