Skip to content

Commit

Permalink
Does not load site_user during db upgrade
Browse files Browse the repository at this point in the history
Fixes #2029 by ensuring we do not attempt to load site_user during a db
upgrade.  This is a workaround because loading the site_user will fail
because of a failed user change.  Should also avoid the problem in
future.
  • Loading branch information
rossjones authored and amercader committed Nov 21, 2014
1 parent cb4f8ec commit c630e77
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions ckan/lib/cli.py
Expand Up @@ -89,7 +89,7 @@ def _get_config(self):
fileConfig(self.filename)
return appconfig('config:' + self.filename)

def _load_config(self):
def _load_config(self, load_site_user=True):
conf = self._get_config()
assert 'ckan' not in dir() # otherwise loggers would be disabled
# We have now loaded the config. Now we can import ckan for the
Expand All @@ -103,7 +103,7 @@ def _load_config(self):
self.translator_obj = MockTranslator()
self.registry.register(pylons.translator, self.translator_obj)

if model.user_table.exists():
if model.user_table.exists() and load_site_user:
# If the DB has already been initialized, create and register
# a pylons context object, and add the site user to it, so the
# auth works as in a normal web request
Expand Down Expand Up @@ -153,11 +153,12 @@ class ManageDb(CkanCommand):
min_args = 1

def command(self):
self._load_config()
cmd = self.args[0]

self._load_config(cmd!='upgrade')
import ckan.model as model
import ckan.lib.search as search

cmd = self.args[0]
if cmd == 'init':

model.repo.init_db()
Expand Down

0 comments on commit c630e77

Please sign in to comment.