From c630e77597c90856d29850bd36801aa6b4dbf596 Mon Sep 17 00:00:00 2001 From: Ross Jones Date: Wed, 19 Nov 2014 17:54:58 +0000 Subject: [PATCH] Does not load site_user during db upgrade 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. --- ckan/lib/cli.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ckan/lib/cli.py b/ckan/lib/cli.py index 6fff5abae26..fe976ed6420 100644 --- a/ckan/lib/cli.py +++ b/ckan/lib/cli.py @@ -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 @@ -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 @@ -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()