Changeset - 9773b46e239f
[Not reviewed]
beta
0 1 0
Marcin Kuzminski - 15 years ago 2011-05-02 15:01:29
marcin@python-works.com
whoosh errors don't crash entire app now, just display an error and log exception instead
1 file changed with 6 insertions and 1 deletions:
0 comments (0 inline, 0 general)
rhodecode/controllers/search.py
Show inline comments
 
@@ -34,13 +34,13 @@ from rhodecode.lib.indexers import SCHEM
 

	
 
from webhelpers.paginate import Page
 
from webhelpers.util import update_params
 

	
 
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__)
 

	
 

	
 
class SearchController(BaseController):
 

	
 
@@ -76,12 +76,14 @@ class SearchController(BaseController):
 
                    cur_query = u'repository:%s %s' % (c.repo_name, cur_query)
 
                try:
 
                    query = qp.parse(unicode(cur_query))
 

	
 
                    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':
 
                                highlight_items.add(i[1])
 

	
 
                    matcher = query.matcher(searcher)
 
@@ -108,9 +110,12 @@ class SearchController(BaseController):
 
                searcher.close()
 
            except (EmptyIndexError, IOError):
 
                log.error(traceback.format_exc())
 
                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')
0 comments (0 inline, 0 general)