Changeset - e9521559d013
[Not reviewed]
default
0 4 0
Mads Kiilerich (mads) - 5 years ago 2020-12-26 18:23:43
mads@kiilerich.com
cli: only config_file_initialize_app should set global CONFIG; needs_config_file will be passed the config object
4 files changed with 7 insertions and 11 deletions:
0 comments (0 inline, 0 general)
kallithea/__init__.py
Show inline comments
 
@@ -39,13 +39,13 @@ BACKENDS = {
 
    'hg': 'Mercurial repository',
 
    'git': 'Git repository',
 
}
 

	
 
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'
 
URL_SEP = '/'
 

	
 
# Linked module for extensions
kallithea/bin/kallithea_cli_base.py
Show inline comments
 
@@ -73,16 +73,14 @@ def register_command(needs_config_file=F
 
                path_to_ini_file = os.path.realpath(config_file)
 
                config = paste.deploy.appconfig('config:' + path_to_ini_file)
 
                cp = configparser.ConfigParser(strict=False)
 
                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 config_file_initialize_app:
 
                    if needs_config_file:  # special case for db creation: also call annotated function (with config parameter) *before* app initialization
 
                if needs_config_file:
 
                        annotated(*args, config=config, **kwargs)
 
                if config_file_initialize_app:
 
                    kallithea.config.application.make_app(config.global_conf, **config.local_conf)
 
                else:
 
                    kallithea.CONFIG = dict(config)  # config is a dict subclass
 
                annotated(*args, **kwargs)
 
            return cli_command(runtime_wrapper)
 
        return annotator
 
    return cli_command
kallithea/bin/kallithea_cli_extensions.py
Show inline comments
 
@@ -21,26 +21,25 @@ Original author and date, and relevant c
 
"""
 
import os
 

	
 
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')
 
    )
 
    ext_file = os.path.join(here, 'extensions.py')
 
    if os.path.exists(ext_file):
 
        msg = ('Extension file %s already exists, do you want '
kallithea/bin/kallithea_cli_iis.py
Show inline comments
 
@@ -13,13 +13,12 @@
 
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
import os
 
import sys
 

	
 
import click
 

	
 
import kallithea
 
import kallithea.bin.kallithea_cli_base as cli_base
 

	
 

	
 
dispath_py_template = '''\
 
# Created by Kallithea 'kallithea-cli iis-install'
 
import sys
 
@@ -57,16 +56,16 @@ if __name__=='__main__':
 
    HandleCommandLine(params)
 
'''
 

	
 
@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
 
        assert isapi_wsgi
 
    except ImportError:
 
        sys.stderr.write('missing requirement: isapi-wsgi not installed\n')
0 comments (0 inline, 0 general)