diff --git a/kallithea/lib/paster_commands/celeryd.py b/kallithea/lib/paster_commands/celeryd.py --- a/kallithea/lib/paster_commands/celeryd.py +++ b/kallithea/lib/paster_commands/celeryd.py @@ -20,9 +20,8 @@ class Command(BasePasterCommand): def take_action(self, args): from kallithea.lib import celerypylons - from tg import config try: - CELERY_ON = str2bool(config['app_conf'].get('use_celery')) + CELERY_ON = str2bool(self.config['app_conf'].get('use_celery')) except KeyError: CELERY_ON = False @@ -31,7 +30,7 @@ class Command(BasePasterCommand): 'file before running celeryd') kallithea.CELERY_ON = CELERY_ON - load_rcextensions(config['here']) + load_rcextensions(self.config['here']) cmd = celerypylons.worker.worker(celerypylons.app.app_or_default()) celery_args = args.celery_args diff --git a/kallithea/lib/paster_commands/common.py b/kallithea/lib/paster_commands/common.py --- a/kallithea/lib/paster_commands/common.py +++ b/kallithea/lib/paster_commands/common.py @@ -31,7 +31,6 @@ import logging.config import paste.deploy import gearbox.command -from tg import config import kallithea.config.middleware import kallithea.model.base @@ -60,6 +59,7 @@ class BasePasterCommand(gearbox.command. # override to control how much get_parser and run should do: takes_config_file = True requires_db_session = True + config = None # set to the actual config object in run if takes_config_file is true def run(self, args): """ @@ -69,13 +69,15 @@ class BasePasterCommand(gearbox.command. """ if self.takes_config_file: path_to_ini_file = os.path.realpath(args.config_file) - conf = paste.deploy.appconfig('config:' + path_to_ini_file) + self.config = paste.deploy.appconfig('config:' + path_to_ini_file) + # TODO: also initialize kallithea.CONFIG? logging.config.fileConfig(path_to_ini_file) if self.requires_db_session: - kallithea.config.middleware.make_app_without_logging(conf.global_conf, **conf.local_conf) - kallithea.lib.utils.setup_cache_regions(config) - engine = kallithea.lib.utils2.engine_from_config(config, 'sqlalchemy.') + kallithea.config.middleware.make_app_without_logging(self.config.global_conf, **self.config.local_conf) + # *now*, tg.config has been set and could be used ... but we just keep using self.config + kallithea.lib.utils.setup_cache_regions(self.config) + engine = kallithea.lib.utils2.engine_from_config(self.config, 'sqlalchemy.') kallithea.model.base.init_model(engine) return super(BasePasterCommand, self).run(args) diff --git a/kallithea/lib/paster_commands/make_index.py b/kallithea/lib/paster_commands/make_index.py --- a/kallithea/lib/paster_commands/make_index.py +++ b/kallithea/lib/paster_commands/make_index.py @@ -40,9 +40,8 @@ class Command(BasePasterCommand): "Kallithea: Create or update full text search index" def take_action(self, args): - from tg import config - index_location = config['index_dir'] - load_rcextensions(config['here']) + index_location = self.config['index_dir'] + load_rcextensions(self.config['here']) repo_location = args.repo_location \ if args.repo_location else RepoModel().repos_path diff --git a/kallithea/lib/paster_commands/make_rcextensions.py b/kallithea/lib/paster_commands/make_rcextensions.py --- a/kallithea/lib/paster_commands/make_rcextensions.py +++ b/kallithea/lib/paster_commands/make_rcextensions.py @@ -44,9 +44,7 @@ class Command(BasePasterCommand): requires_db_session = False def take_action(self, args): - from tg import config - - here = config['here'] + here = self.config['here'] content = pkg_resources.resource_string( 'kallithea', os.path.join('config', 'rcextensions', '__init__.py') ) diff --git a/kallithea/lib/paster_commands/setup_db.py b/kallithea/lib/paster_commands/setup_db.py --- a/kallithea/lib/paster_commands/setup_db.py +++ b/kallithea/lib/paster_commands/setup_db.py @@ -91,11 +91,8 @@ class Command(BasePasterCommand): return parser def take_action(self, opts): - path_to_ini_file = os.path.realpath(opts.config_file) - conf = paste.deploy.appconfig('config:' + path_to_ini_file) - - dbconf = conf['sqlalchemy.url'] - dbmanage = DbManage(dbconf=dbconf, root=conf['here'], + dbconf = self.config['sqlalchemy.url'] + dbmanage = DbManage(dbconf=dbconf, root=self.config['here'], tests=False, cli_args=vars(opts)) dbmanage.create_tables(override=True) opts = dbmanage.config_prompt(None)