Changeset - 21d210d29d7f
[Not reviewed]
default
0 2 0
Thomas De Schampheleire - 9 years ago 2017-04-14 21:19:42
thomas.de.schampheleire@gmail.com
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.
2 files changed with 5 insertions and 3 deletions:
0 comments (0 inline, 0 general)
kallithea/config/middleware.py
Show inline comments
 
@@ -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)
kallithea/lib/paster_commands/common.py
Show inline comments
 
@@ -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)
0 comments (0 inline, 0 general)