changeset 6595:21d210d29d7f

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.
author Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
date Fri, 14 Apr 2017 21:19:42 +0200
parents a844ea41da7e
children 304aae43194c
files kallithea/config/middleware.py kallithea/lib/paster_commands/common.py
diffstat 2 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/config/middleware.py	Thu Apr 13 02:05:24 2017 +0200
+++ b/kallithea/config/middleware.py	Fri Apr 14 21:19:42 2017 +0200
@@ -23,6 +23,9 @@
 # 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 @@
     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)
--- a/kallithea/lib/paster_commands/common.py	Thu Apr 13 02:05:24 2017 +0200
+++ b/kallithea/lib/paster_commands/common.py	Fri Apr 14 21:19:42 2017 +0200
@@ -71,7 +71,7 @@
             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)