def __getitem__(self, key):
return self._registry[key]
+
+ def __iter__(self):
+ return self._registry.__iter__()
registry = SearchRegistry()
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)
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):
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 {}
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):
"""