Mercurial > kallithea
diff rhodecode/controllers/search.py @ 2031:82a88013a3fd
merge 1.3 into stable
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sun, 26 Feb 2012 17:25:09 +0200 |
parents | bf263968da47 b6c902d88472 |
children | 63e58ef80ef1 |
line wrap: on
line diff
--- a/rhodecode/controllers/search.py Sun Feb 19 20:21:14 2012 +0200 +++ b/rhodecode/controllers/search.py Sun Feb 26 17:25:09 2012 +0200 @@ -7,7 +7,7 @@ :created_on: Aug 7, 2010 :author: marcink - :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com> + :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com> :license: GPLv3, see COPYING for more details. """ # This program is free software: you can redistribute it and/or modify @@ -26,7 +26,7 @@ import traceback from pylons.i18n.translation import _ -from pylons import request, config, session, tmpl_context as c +from pylons import request, config, tmpl_context as c from rhodecode.lib.auth import LoginRequired from rhodecode.lib.base import BaseController, render @@ -76,7 +76,7 @@ cur_query = u'repository:%s %s' % (c.repo_name, cur_query) try: query = qp.parse(unicode(cur_query)) - + # extract words for highlight if isinstance(query, Phrase): highlight_items.update(query.words) elif isinstance(query, Prefix): @@ -92,18 +92,22 @@ log.debug(highlight_items) results = searcher.search(query) res_ln = len(results) - c.runtime = '%s results (%.3f seconds)' \ - % (res_ln, results.runtime) + c.runtime = '%s results (%.3f seconds)' % ( + res_ln, results.runtime + ) def url_generator(**kw): return update_params("?q=%s&type=%s" \ % (c.cur_query, c.cur_search), **kw) c.formated_results = Page( - ResultWrapper(search_type, searcher, matcher, - highlight_items), - page=p, item_count=res_ln, - items_per_page=10, url=url_generator) + ResultWrapper(search_type, searcher, matcher, + highlight_items), + page=p, + item_count=res_ln, + items_per_page=10, + url=url_generator + ) except QueryParserError: c.runtime = _('Invalid search query. Try quoting it.') @@ -117,5 +121,6 @@ log.error(traceback.format_exc()) c.runtime = _('An error occurred during this search operation') + # Return a rendered template return render('/search/search.html')