Mercurial > moin > 1.9
changeset 980:f472ddeba121
SystemInfo macro extended with the state of the index, ensure fallback to moinSearch
author | Franz Pletz <fpletz AT franz-pletz DOT org> |
---|---|
date | Mon, 17 Jul 2006 12:24:58 +0200 |
parents | b8c1bb917748 |
children | dbb3bf01ae19 |
files | MoinMoin/macro/SystemInfo.py MoinMoin/search/Xapian.py MoinMoin/search/builtin.py docs/CHANGES.fpletz |
diffstat | 4 files changed, 25 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/MoinMoin/macro/SystemInfo.py Mon Jul 17 12:17:39 2006 +0200 +++ b/MoinMoin/macro/SystemInfo.py Mon Jul 17 12:24:58 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 12:17:39 2006 +0200 +++ b/MoinMoin/search/Xapian.py Mon Jul 17 12:24:58 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:
--- a/MoinMoin/search/builtin.py Mon Jul 17 12:17:39 2006 +0200 +++ b/MoinMoin/search/builtin.py Mon Jul 17 12:24:58 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 12:17:39 2006 +0200 +++ b/docs/CHANGES.fpletz Mon Jul 17 12:24:58 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 +