# HG changeset patch # User Thomas De Schampheleire # Date 2017-04-14 21:19:42 # Node ID 21d210d29d7f1942ac948badb3457555fd2331c2 # Parent a844ea41da7ea96fc013ec9791376b61cc2e37c8 gearbox: avoid duplicate logging setup when calling make_app make_app initialized logging, while the gearbox common code does it too. Split make_app in two to be able to avoid the redundant call. The logging setup in make_app cannot be removed because it is needed for 'gearbox serve' and direct WSGI invocation, which does not pass through gearbox common.py. diff --git a/kallithea/config/middleware.py b/kallithea/config/middleware.py --- a/kallithea/config/middleware.py +++ b/kallithea/config/middleware.py @@ -23,6 +23,9 @@ __all__ = ['make_app'] # make_base_app will wrap the TurboGears2 app with all the middleware it needs. make_base_app = base_config.setup_tg_wsgi_app(load_environment) +def make_app_without_logging(global_conf, full_stack=True, **app_conf): + """The core of make_app for use from gearbox commands (other than 'serve')""" + return make_base_app(global_conf, full_stack=full_stack, **app_conf) def make_app(global_conf, full_stack=True, **app_conf): """ @@ -43,5 +46,4 @@ def make_app(global_conf, full_stack=Tru under ``[app:main]``. """ logging.config.fileConfig(global_conf['__file__']) - app = make_base_app(global_conf, full_stack=full_stack, **app_conf) - return app + return make_app_without_logging(global_conf, full_stack=full_stack, **app_conf) 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 @@ -71,7 +71,7 @@ class BasePasterCommand(gearbox.command. 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(conf.global_conf, **conf.local_conf) + kallithea.config.middleware.make_app_without_logging(conf.global_conf, **conf.local_conf) if self.requires_db_session: kallithea.lib.utils.setup_cache_regions(config)