X-Git-Url: http://git.ithinksw.org/philo.git/blobdiff_plain/a7be420f379ae5c6318ea815ea24bac5a4ca4b61..82b08f79564159d7acbcaf255ed1ac1fb4882e64:/contrib/sobol/search.py diff --git a/contrib/sobol/search.py b/contrib/sobol/search.py index 2999680..39b93c7 100644 --- a/contrib/sobol/search.py +++ b/contrib/sobol/search.py @@ -175,7 +175,7 @@ class BaseSearch(object): limit = self.result_limit if limit is not None: limit += 1 - results = self.get_results(self.result_limit) + results = self.get_results(limit) except: if settings.DEBUG: raise @@ -252,9 +252,6 @@ class BaseSearch(object): class DatabaseSearch(BaseSearch): model = None - def has_more_results(self): - return self.get_queryset().count() > self.result_limit - def search(self, limit=None): if not hasattr(self, '_qs'): self._qs = self.get_queryset() @@ -303,10 +300,21 @@ class JSONSearch(URLSearch): class GoogleSearch(JSONSearch): search_url = "http://ajax.googleapis.com/ajax/services/search/web" - query_format_str = "?v=1.0&q=%s" # TODO: Change this template to reflect the app's actual name. result_template = 'search/googlesearch.html' _cache_timeout = 60 + verbose_name = "Google search (current site)" + + @property + def query_format_str(self): + default_args = self.default_args + if default_args: + default_args += " " + return "?v=1.0&q=%s%%s" % urlquote_plus(default_args).replace('%', '%%') + + @property + def default_args(self): + return "site:%s" % Site.objects.get_current().domain def parse_response(self, response, limit=None): responseData = json.loads(response.read())['responseData']