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
 
@@ -20,12 +20,15 @@ from kallithea.config.environment import
 
__all__ = ['make_app']
 

	
 
# Use base_config to setup the necessary PasteDeploy application factory.
 
# 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):
 
    """
 
    Set up Kallithea with the settings found in the PasteDeploy configuration
 
    file used.
 

	
 
@@ -40,8 +43,7 @@ def make_app(global_conf, full_stack=Tru
 
    This is the PasteDeploy factory for the Kallithea application.
 

	
 
    ``app_conf`` contains all the application-specific settings (those defined
 
    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
 
@@ -68,13 +68,13 @@ class BasePasterCommand(gearbox.command.
 
        If needed by the command, read config file and initialize database before running.
 
        """
 
        if self.takes_config_file:
 
            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)
 
                engine = kallithea.lib.utils2.engine_from_config(config, 'sqlalchemy.')
 
                kallithea.model.base.init_model(engine)
 

	
0 comments (0 inline, 0 general)