X-Git-Url: http://git.ithinksw.org/philo.git/blobdiff_plain/62a418ca34a8d4e8323e1c998c21b5e957739fd9..43595c8f3220d11f47554e9755f5b54e283f635e:/contrib/sobol/search.py?ds=sidebyside diff --git a/contrib/sobol/search.py b/contrib/sobol/search.py index cce3ec6..4f89e76 100644 --- a/contrib/sobol/search.py +++ b/contrib/sobol/search.py @@ -69,6 +69,9 @@ class SearchRegistry(object): def __getitem__(self, key): return self._registry[key] + + def __iter__(self): + return self._registry.__iter__() registry = SearchRegistry() @@ -90,7 +93,7 @@ class Result(object): return self.search.get_result_title(self.result) def get_url(self): - return self.search.get_result_querydict(self.result).urlencode() + return "?%s" % self.search.get_result_querydict(self.result).urlencode() def get_template(self): return self.search.get_result_template(self.result) @@ -98,13 +101,17 @@ class Result(object): def get_extra_context(self): return self.search.get_result_extra_context(self.result) - def render(self): - t = self.get_template() - c = Context(self.get_extra_context()) - c.update({ + def get_context(self): + context = self.get_extra_context() + context.update({ 'title': self.get_title(), 'url': self.get_url() }) + return context + + def render(self): + t = self.get_template() + c = Context(self.get_context()) return t.render(c) def __unicode__(self): @@ -211,9 +218,6 @@ class BaseSearch(object): self._result_template = Template(DEFAULT_RESULT_TEMPLATE_STRING) return self._result_template - def get_ajax_result_template(self, result): - return getattr(self, 'ajax_result_template', DEFAULT_RESULT_TEMPLATE_STRING) - def get_result_extra_context(self, result): return {} @@ -357,7 +361,7 @@ else: def parse_response(self, response, limit=None): strainer = self.strainer soup = BeautifulSoup(response, parseOnlyThese=strainer) - return self.parse_results(soup[:limit]) + return self.parse_results(soup.findAll(recursive=False, limit=limit)) def parse_results(self, results): """