[ckan-changes] commit/ckan: 5 new changesets

Bitbucket commits-noreply at bitbucket.org
Wed Aug 24 15:16:14 UTC 2011


5 new changesets in ckan:

http://bitbucket.org/okfn/ckan/changeset/87044825603f/
changeset:   87044825603f
branch:      feature-1275-solr-search
user:        John Glover
date:        2011-08-24 15:22:08
summary:     [solr] search_enabled doesn't really need to be set in the ckan config so no need to try and read it
affected #:  2 files (85 bytes)

--- a/ckan/config/environment.py	Tue Aug 23 18:19:44 2011 +0100
+++ b/ckan/config/environment.py	Wed Aug 24 14:22:08 2011 +0100
@@ -75,11 +75,10 @@
 
     # check that search is available, disable if not
     import ckan.lib.search as search
-    if not config.get('search_enabled', '') == 'False':
-        config['search_enabled'] = search.is_available()
-    else:
-        # save this as a boolean rather than a string
-        config['search_enabled'] = False
+    config['search_enabled'] = search.is_available()
+    if not config.get('search_enabled'):
+        log = logging.getLogger(__name__)
+        log.error("Solr not available, disabling package search.")
     
     config['routes.map'] = make_map()
     config['pylons.app_globals'] = app_globals.Globals()


--- a/ckan/lib/search/common.py	Tue Aug 23 18:19:44 2011 +0100
+++ b/ckan/lib/search/common.py	Wed Aug 24 14:22:08 2011 +0100
@@ -13,12 +13,12 @@
         conn = make_connection(config)
         conn.query("*:*", rows=1)
         conn.close()
-        return True
     except Exception, e:
-        log.error("Solr not available, disabling package search.")
         log.exception(e)
         return False
 
+    return True
+
 def is_enabled():
     """
     Return true if search is enabled in ckan config.


http://bitbucket.org/okfn/ckan/changeset/74712bd74368/
changeset:   74712bd74368
branch:      feature-1275-solr-search
user:        John Glover
date:        2011-08-24 15:52:36
summary:     [solr] don't show the search count if there was an error
affected #:  1 file (8 bytes)

--- a/ckan/templates/package/search.html	Wed Aug 24 14:22:08 2011 +0100
+++ b/ckan/templates/package/search.html	Wed Aug 24 14:52:36 2011 +0100
@@ -51,9 +51,9 @@
     
       <py:if test="c.query_error"><p i18n:msg="item_count"><strong>There was an error while searching.</strong> 
-            Please try another search term.</p>
+            Please try again.</p></py:if>
-      <py:if test="request.params">      
+      <py:if test="request.params and not c.query_error"><h4 i18n:msg="item_count"><strong>${c.page.item_count}</strong> packages found</h4></py:if><py:if test="c.page.item_count == 0 and request.params">


http://bitbucket.org/okfn/ckan/changeset/82505fecacff/
changeset:   82505fecacff
branch:      feature-1275-solr-search
user:        John Glover
date:        2011-08-24 15:55:02
summary:     [solr] [1154] Don't need to check if search is enabled before queries, controllers should catch any SearchErrors
affected #:  2 files (67 bytes)

--- a/ckan/lib/search/common.py	Wed Aug 24 14:52:36 2011 +0100
+++ b/ckan/lib/search/common.py	Wed Aug 24 14:55:02 2011 +0100
@@ -23,7 +23,7 @@
     """
     Return true if search is enabled in ckan config.
     """
-    return config.get('search_enabled')
+    return config.get('search_enabled', True)
 
 def make_connection(config):
     url = config.get('solr_url', 'http://localhost:8983/solr')


--- a/ckan/lib/search/query.py	Wed Aug 24 14:52:36 2011 +0100
+++ b/ckan/lib/search/query.py	Wed Aug 24 14:55:02 2011 +0100
@@ -4,7 +4,7 @@
 from paste.deploy.converters import asbool
 from ckan import model
 from ckan.authz import Authorizer
-from common import is_enabled, make_connection, SearchError
+from common import make_connection, SearchError
 import logging
 log = logging.getLogger(__name__)
 
@@ -267,9 +267,6 @@
 
 class PackageSearchQuery(SearchQuery):
     def _run(self):
-        if not is_enabled():
-            return
-
         fq = ""
 
         # Filter for options


http://bitbucket.org/okfn/ckan/changeset/4e5d66025893/
changeset:   4e5d66025893
branch:      feature-1275-solr-search
user:        John Glover
date:        2011-08-24 16:54:28
summary:     [solr] [1154] Update home controller to catch search errors and display an error message
affected #:  3 files (124 bytes)

--- a/ckan/controllers/home.py	Wed Aug 24 14:55:02 2011 +0100
+++ b/ckan/controllers/home.py	Wed Aug 24 15:54:28 2011 +0100
@@ -44,17 +44,25 @@
     def index(self):
         cache_key = self._home_cache_key()
         etag_cache(cache_key)
+        c.query_error = False
+        c.fields = []
 
-        query = query_for(model.Package)
-        query.run(query='*:*', facet_by=g.facets,
-                  limit=0, offset=0, username=c.user,
-                  order_by=None)
-        c.facets = query.facets
-        c.fields = []
-        c.package_count = query.count
-        c.latest_packages = get_action('current_package_list_with_resources')({'model': model,
-                                                                 'user': c.user},
-                                                                 {'limit': 5})      
+        try:
+            query = query_for(model.Package)
+            query.run(query='*:*', facet_by=g.facets,
+                      limit=0, offset=0, username=c.user,
+                      order_by=None)
+            c.facets = query.facets
+            c.package_count = query.count
+        except SearchError, se:
+            c.query_error = True
+            c.facets = {}
+            c.package_count = 0
+
+        c.latest_packages = get_action('current_package_list_with_resources')(
+            {'model': model, 'user': c.user},
+            {'limit': 5}
+        )      
         return render('home/index.html', cache_key=cache_key,
                       cache_expire=cache_expires)
 


--- a/ckan/templates/home/index.html	Wed Aug 24 14:55:02 2011 +0100
+++ b/ckan/templates/home/index.html	Wed Aug 24 15:54:28 2011 +0100
@@ -49,7 +49,7 @@
     </p><div py:if="g.search_enabled">
-      <p i18n:msg="package_count"><strong>${c.package_count} registered data packages</strong> available.</p>
+      <p py:if="not c.query_error" i18n:msg="package_count"><strong>${c.package_count} registered data packages</strong> available.</p><xi:include href="../package/search_form.html" /></div>


--- a/ckan/tests/functional/test_package.py	Wed Aug 24 14:55:02 2011 +0100
+++ b/ckan/tests/functional/test_package.py	Wed Aug 24 15:54:28 2011 +0100
@@ -397,7 +397,7 @@
         results_page = self.app.get(offset)
         assert 'Search - ' in results_page, results_page
         results_page = self.main_div(results_page)
-        assert '<strong>0</strong>' in results_page, results_page
+        assert 'error while searching' in results_page, results_page
 
     def _check_search_results(self, page, terms, requireds, only_open=False, only_downloadable=False):
         form = page.forms['package-search']


http://bitbucket.org/okfn/ckan/changeset/fd427906eaeb/
changeset:   fd427906eaeb
branch:      feature-1275-solr-search
user:        John Glover
date:        2011-08-24 16:56:31
summary:     [solr] merge with default
affected #:  6 files (1.0 KB)

--- a/ckan/lib/cli.py	Wed Aug 24 15:54:28 2011 +0100
+++ b/ckan/lib/cli.py	Wed Aug 24 15:56:31 2011 +0100
@@ -38,9 +38,7 @@
             msg = 'No config file supplied'
             raise self.BadCommand(msg)
         self.filename = os.path.abspath(self.options.config)
-        try:
-            fileConfig(self.filename)
-        except Exception: pass
+        fileConfig(self.filename)
         conf = appconfig('config:' + self.filename)
         load_environment(conf.global_conf, conf.local_conf)
 


--- a/ckan/model/modification.py	Wed Aug 24 15:54:28 2011 +0100
+++ b/ckan/model/modification.py	Wed Aug 24 15:56:31 2011 +0100
@@ -1,3 +1,5 @@
+import logging
+
 from vdm.sqlalchemy import State
 
 from sqlalchemy.orm import object_session
@@ -14,6 +16,7 @@
 from ckan.model.package_extra import PackageExtra
 from ckan.model.tag import PackageTag
 
+log = logging.getLogger(__name__)
 
 class DomainObjectModificationExtension(SingletonPlugin, ObserverNotifier):
     """
@@ -63,4 +66,10 @@
 
     def notify(self, entity, operation):
         for observer in self.observers:
-            observer.notify(entity, operation)
+            try:
+                observer.notify(entity, operation)
+            except Exception, ex:
+                log.exception(ex)
+                # We reraise all exceptions so they are obvious there
+                # is something wrong
+                raise


--- a/ckan/model/package.py	Wed Aug 24 15:54:28 2011 +0100
+++ b/ckan/model/package.py	Wed Aug 24 15:56:31 2011 +0100
@@ -333,13 +333,13 @@
         return [(l.title, l.id) for l in register.values()]
 
     def get_license(self):
-        license = None
         if self.license_id:
             try:
                 license = self.get_license_register()[self.license_id]
-            except Exception, inst:
-                # Todo: Log a warning.
-                pass
+            except KeyError:
+                license = None
+        else:
+            license = None
         return license
 
     def set_license(self, license):


--- a/ckan/plugins/interfaces.py	Wed Aug 24 15:54:28 2011 +0100
+++ b/ckan/plugins/interfaces.py	Wed Aug 24 15:56:31 2011 +0100
@@ -167,7 +167,7 @@
 
 class IDomainObjectModification(Interface):
     """
-    Receives notification of new, changed and deleted domain objects
+    Receives notification of new, changed and deleted domain objects.
     """
 
     def notify(self, entity, operation):


--- a/ckan/tests/models/test_changeset.py	Wed Aug 24 15:54:28 2011 +0100
+++ b/ckan/tests/models/test_changeset.py	Wed Aug 24 15:56:31 2011 +0100
@@ -10,6 +10,10 @@
 import ckan.model as model
 from ckan.model import setup_default_user_roles
 
+# Changesets deprecated - tests skipped (see #1002)
+from nose.plugins.skip import SkipTest
+raise SkipTest()
+
 class TestCase(object):
 
     def setup(self):


--- a/doc/install-from-source.rst	Wed Aug 24 15:54:28 2011 +0100
+++ b/doc/install-from-source.rst	Wed Aug 24 15:56:31 2011 +0100
@@ -2,21 +2,15 @@
 Option 2: Install from Source
 =============================
 
-This section describes how to install CKAN from source. This removes the requirement for Ubuntu 10.04 that exists with :doc:`install-from-package`.
+This section describes how to install CKAN from source. This removes the requirement for Ubuntu 10.04 that exists with :doc:`install-from-package`. It is also the option to use if you are going to develop the CKAN source.
 
-.. warning:: This option is more complex than :doc:`install-from-package`, so f you prefer simplicity we suggest installing from package. 
+.. warning:: This option is more complex than :doc:`install-from-package`.
 
 For support during installation, please contact `the ckan-dev mailing list <http://lists.okfn.org/mailman/listinfo/ckan-dev>`_. 
 
 Install the Source
 ------------------
 
-These are instructions to get developing with CKAN.
-
-Before you start, it may be worth `checking CKAN has passed the auto build and
-tests <http://buildbot.okfn.org/waterfall>`_. 
-
-
 1. Ensure the required packages are installed.
 
    If you have access to ``apt-get``, you can install these packages as follows:
@@ -95,13 +89,15 @@
 
    An activated shell looks in your virtual environment first when choosing
    which commands to run. If you enter ``python`` now it will actually 
-   run ``~/pyenv/bin/python`` which is what you want.
+   run ``~/pyenv/bin/python``, not the default ``/usr/bin/python`` which is what you want for CKAN. You can install python packages install this new environment and they won't affect the default ``/usr/bin/python``. This is necessary so you can use particular versions of python packages, rather than the ones installed with default paython, and these installs do not affect other python software on your system that may not be compatible with these packages.
 
-4. Install CKAN code and required Python packages into the new environment.
+4. Install CKAN code and other required Python packages into the new environment.
 
-   First you'll need to install CKAN. For the latest version run:
+   Choose which version of CKAN to install. Released versions are listed at https://bitbucket.org/okfn/ckan - click on the list of tags. For example: ``ckan-1.4.2``
 
-   ::
+       pip install --ignore-installed -e hg+http://bitbucket.org/okfn/ckan@ckan-1.4.2#egg=ckan
+
+   Alternatively, if you are to develop CKAN, then you will probably want to use the latest 'bleeding edge' code. If using this version, we suggest you `check CKAN has passed the automatic tests <http://buildbot.okfn.org/waterfall>`_. Here is how to install the latest code::
 
        pip install --ignore-installed -e hg+http://bitbucket.org/okfn/ckan#egg=ckan
 
@@ -185,17 +181,13 @@
   Paste and other modules are put on the python path (your command prompt will
   start with ``(pyenv)`` if you have) then change into the ``ckan`` directory
   which will have been created when you installed CKAN in step 4 and create the
-  config file ``development.ini`` using Paste:
+  CKAN config file using Paste. These instructions call it ``development.ini`` since that is the required name for running the CKAN tests. But for a server deployment then you might want to call it say after the server hostname e.g. ``test.ckan.net.ini``.
 
   ::
 
       cd pyenv/src/ckan
       paster make-config ckan development.ini
 
-  You can give your config file a different name but the tests will expect you
-  to have used ``development.ini`` so it is strongly recommended you use this
-  name, at least to start with.
-
   If you used a different database name or password when creating the database
   in step 5 you'll need to now edit ``development.ini`` and change the
   ``sqlalchemy.url`` line, filling in the database name, user and password you used.
@@ -210,10 +202,9 @@
 
   .. caution ::
 
-     Advanced users: If you are using CKAN's fab file capability you currently need to create
-     your config file as ``pyenv/ckan.net.ini`` so you will probably have 
-     ignored the advice about creating a ``development.ini`` file in the 
-     ``pyenv/src/ckan`` directory. This is fine but CKAN probably won't be 
+     Advanced users: If you have installed CKAN using the Fabric file capability (deprecated),
+     your config file will be called something like ``pyenv/ckan.net.ini``. 
+     This is fine but CKAN probably won't be 
      able to find your ``who.ini`` file. To fix this edit ``pyenv/ckan.net.ini``, 
      search for the line ``who.config_file = %(here)s/who.ini`` and change it
      to ``who.config_file = who.ini``.

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