Mercurial > kallithea
changeset 1303:9773b46e239f beta
whoosh errors don't crash entire app now, just display an error and log exception instead
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Mon, 02 May 2011 15:01:29 +0200 |
parents | f0e904651f21 |
children | 5a96551ee9c0 |
files | rhodecode/controllers/search.py |
diffstat | 1 files changed, 6 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/rhodecode/controllers/search.py Mon May 02 14:42:51 2011 +0200 +++ b/rhodecode/controllers/search.py Mon May 02 15:01:29 2011 +0200 @@ -37,7 +37,7 @@ from whoosh.index import open_dir, EmptyIndexError from whoosh.qparser import QueryParser, QueryParserError -from whoosh.query import Phrase +from whoosh.query import Phrase, Wildcard, Term, Prefix log = logging.getLogger(__name__) @@ -79,6 +79,8 @@ if isinstance(query, Phrase): highlight_items.update(query.words) + elif isinstance(query, Prefix): + highlight_items.add(query.text) else: for i in query.all_terms(): if i[0] == 'content': @@ -111,6 +113,9 @@ log.error('Empty Index data') c.runtime = _('There is no index to search in. ' 'Please run whoosh indexer') + except (Exception): + log.error(traceback.format_exc()) + c.runtime = _('An error occurred during this search operation') # Return a rendered template return render('/search/search.html')