Skip to content

Commit

Permalink
[1597] Allows use of environment var for specifying config file.
Browse files Browse the repository at this point in the history
Implements #1597

If you don't specify a config file using the -c option, CKAN defaults to
looking for development.ini in the current directory.  This patch will
first check the -c parameter, and if it doesn't find it will use the content
of the CKAN_INI environment variable.  If it cannot find that, it will then
default to development.ini in the current directory.

This does not work with paster serve as this is handled by pastescript which
specifically requires the -c paramter.
  • Loading branch information
rossjones committed Mar 13, 2014
1 parent 82c6b07 commit 1b7eb02
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions ckan/lib/cli.py
Expand Up @@ -80,12 +80,17 @@ class CkanCommand(paste.script.command.Command):

def _get_config(self):
from paste.deploy import appconfig
if not self.options.config:
msg = 'No config file supplied'
raise self.BadCommand(msg)
self.filename = os.path.abspath(self.options.config)

self.filename = os.environ.get('CKAN_INI',
os.path.abspath('development.ini'))

if self.options.config:
self.filename = os.path.abspath(self.options.config)

if not os.path.exists(self.filename):
raise AssertionError('Config filename %r does not exist.' % self.filename)
msg = 'No config file supplied or found in $CKAN_INI'
raise self.BadCommand(msg)

fileConfig(self.filename)
return appconfig('config:' + self.filename)

Expand Down Expand Up @@ -389,7 +394,7 @@ class SearchIndexCommand(CkanCommand):
Usage:
search-index [-i] [-o] [-r] [-e] rebuild [dataset_name] - reindex dataset_name if given, if not then rebuild
full search index (all datasets)
search-index rebuild_fast - reindex using multiprocessing using all cores.
search-index rebuild_fast - reindex using multiprocessing using all cores.
This acts in the same way as rubuild -r [EXPERIMENTAL]
search-index check - checks for datasets not indexed
search-index show DATASET_NAME - shows index of a dataset
Expand Down

0 comments on commit 1b7eb02

Please sign in to comment.