# HG changeset patch # User Mads Kiilerich # Date 1492198242 -7200 # Node ID 304aae43194c5fc8c25157cc4c4d6badffff9aac # Parent 21d210d29d7f1942ac948badb3457555fd2331c2 gearbox: fix setup-db failure when db is created for the first time (Issue #272) The port to TG2 in e1ab82613133 replaced pylonsconfig.init_app for gearbox commands with middleware setup code. That introduced reading of the database for commands that don't need a database - for example the command for creating databases ... which thus failed. To fix that, move the middleware setup with database access so it only is run for gearbox command that requires a db session. There is apparently no need for a direct replacement for pylonsconfig.init_app . diff -r 21d210d29d7f -r 304aae43194c kallithea/lib/paster_commands/common.py --- a/kallithea/lib/paster_commands/common.py Fri Apr 14 21:19:42 2017 +0200 +++ b/kallithea/lib/paster_commands/common.py Fri Apr 14 21:30:42 2017 +0200 @@ -71,9 +71,9 @@ path_to_ini_file = os.path.realpath(args.config_file) conf = paste.deploy.appconfig('config:' + path_to_ini_file) logging.config.fileConfig(path_to_ini_file) - kallithea.config.middleware.make_app_without_logging(conf.global_conf, **conf.local_conf) 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.model.base.init_model(engine)