[ckan-changes] commit/ckan: John Glover: [1342][xs] Bug fix: catch SearchErrors in home controller and don't display 'who else is here' heading in home template if there are search errors or no results

Bitbucket commits-noreply at bitbucket.org
Tue Sep 27 13:51:46 UTC 2011


1 new changeset in ckan:

http://bitbucket.org/okfn/ckan/changeset/05f60f2d26e8/
changeset:   05f60f2d26e8
user:        John Glover
date:        2011-09-27 15:51:31
summary:     [1342][xs] Bug fix: catch SearchErrors in home controller and don't display 'who else is here' heading in home template if there are search errors or no results
affected #:  2 files (-1 bytes)

--- a/ckan/controllers/home.py	Tue Sep 27 10:55:17 2011 +0100
+++ b/ckan/controllers/home.py	Tue Sep 27 14:51:31 2011 +0100
@@ -57,15 +57,17 @@
     def index(self):
         cache_key = self._home_cache_key()
         etag_cache(cache_key)
-        c.query_error = False
 
-        query = query_for(model.Package)
-        query.run({'q': '*:*', 'facet.field': g.facets})
-        c.fields = []
-        c.facets = query.facets
-        c.package_count = query.count
-        q = model.Session.query(model.Group).filter_by(state='active')
-        c.groups = sorted(q.all(), key=lambda g: len(g.packages), reverse=True)[:6]
+        try:
+            query = query_for(model.Package)
+            query.run({'q': '*:*'})
+            c.package_count = query.count
+            q = model.Session.query(model.Group).filter_by(state='active')
+            c.groups = sorted(q.all(), key=lambda g: len(g.packages), reverse=True)[:6]
+        except SearchError, se:
+            c.package_count = 0
+            c.groups = []
+
         return render('home/index.html', cache_key=cache_key,
                       cache_expire=cache_expires)
 


--- a/ckan/templates/home/index.html	Tue Sep 27 10:55:17 2011 +0100
+++ b/ckan/templates/home/index.html	Tue Sep 27 14:51:31 2011 +0100
@@ -49,7 +49,7 @@
         </ul></div></div>
-      <div class="span-24 last whoelse">
+      <div py:if="c.groups" class="span-24 last whoelse"><h2>Who else is here?</h2></div><py:for each="i, group in enumerate(c.groups)">

Repository URL: https://bitbucket.org/okfn/ckan/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.




More information about the ckan-changes mailing list