Mercurial > kallithea
changeset 8825:e9521559d013
cli: only config_file_initialize_app should set global CONFIG; needs_config_file will be passed the config object
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Sat, 26 Dec 2020 18:23:43 +0100 |
parents | 04c8edacc3a1 |
children | 7a73baa4c66c |
files | kallithea/__init__.py kallithea/bin/kallithea_cli_base.py kallithea/bin/kallithea_cli_extensions.py kallithea/bin/kallithea_cli_iis.py |
diffstat | 4 files changed, 8 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/__init__.py Sat Dec 26 18:14:26 2020 +0100 +++ b/kallithea/__init__.py Sat Dec 26 18:23:43 2020 +0100 @@ -42,7 +42,7 @@ CELERY_APP = None # set to Celery app instance if using Celery -CONFIG = {} +CONFIG = {} # set to tg.config when TG app is initialized and calls app_cfg # URL prefix for non repository related links - must start with `/` ADMIN_PREFIX = '/_admin'
--- a/kallithea/bin/kallithea_cli_base.py Sat Dec 26 18:14:26 2020 +0100 +++ b/kallithea/bin/kallithea_cli_base.py Sat Dec 26 18:23:43 2020 +0100 @@ -76,13 +76,11 @@ cp.read_string(read_config(path_to_ini_file, strip_section_prefix=annotated.__name__)) logging.config.fileConfig(cp, {'__file__': path_to_ini_file, 'here': os.path.dirname(path_to_ini_file)}) + if needs_config_file: + annotated(*args, config=config, **kwargs) if config_file_initialize_app: - if needs_config_file: # special case for db creation: also call annotated function (with config parameter) *before* app initialization - annotated(*args, config=config, **kwargs) kallithea.config.application.make_app(config.global_conf, **config.local_conf) - else: - kallithea.CONFIG = dict(config) # config is a dict subclass - annotated(*args, **kwargs) + annotated(*args, **kwargs) return cli_command(runtime_wrapper) return annotator return cli_command
--- a/kallithea/bin/kallithea_cli_extensions.py Sat Dec 26 18:14:26 2020 +0100 +++ b/kallithea/bin/kallithea_cli_extensions.py Sat Dec 26 18:23:43 2020 +0100 @@ -24,20 +24,19 @@ import click import pkg_resources -import kallithea import kallithea.bin.kallithea_cli_base as cli_base from kallithea.lib.utils2 import ask_ok @cli_base.register_command(needs_config_file=True) -def extensions_create(): +def extensions_create(config): """Write template file for extending Kallithea in Python. Create a template `extensions.py` file next to the ini file. Local customizations in that file will survive upgrades. The file contains instructions on how it can be customized. """ - here = kallithea.CONFIG['here'] + here = config['here'] content = pkg_resources.resource_string( 'kallithea', os.path.join('templates', 'py', 'extensions.py') )
--- a/kallithea/bin/kallithea_cli_iis.py Sat Dec 26 18:14:26 2020 +0100 +++ b/kallithea/bin/kallithea_cli_iis.py Sat Dec 26 18:23:43 2020 +0100 @@ -16,7 +16,6 @@ import click -import kallithea import kallithea.bin.kallithea_cli_base as cli_base @@ -60,10 +59,10 @@ @cli_base.register_command(needs_config_file=True) @click.option('--virtualdir', default='/', help='The virtual folder to install into on IIS.') -def iis_install(virtualdir): +def iis_install(virtualdir, config): """Install into IIS using isapi-wsgi.""" - config_file_abs = kallithea.CONFIG['__file__'] + config_file_abs = config['__file__'] try: import isapi_wsgi