Mercurial > kallithea
changeset 8545:3a02b678b5e7
tg: move make_app to kallithea/config/application.py per TG 2.4 convention
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Thu, 23 Apr 2020 21:45:27 +0200 |
parents | cf0620647130 |
children | f644fc6bbfc3 |
files | docs/overview.rst kallithea/bin/kallithea_cli_base.py kallithea/bin/kallithea_cli_db.py kallithea/config/application.py kallithea/config/middleware.py kallithea/lib/hooks.py setup.py |
diffstat | 7 files changed, 54 insertions(+), 54 deletions(-) [+] |
line wrap: on
line diff
--- a/docs/overview.rst Fri Apr 24 15:17:54 2020 +0200 +++ b/docs/overview.rst Thu Apr 23 21:45:27 2020 +0200 @@ -172,7 +172,7 @@ The web server used by ``gearbox`` is configured in the ``.ini`` file passed to it. The entry point for the WSGI application is configured - in ``setup.py`` as ``kallithea.config.middleware:make_app``. + in ``setup.py`` as ``kallithea.config.application:make_app``. - `Apache httpd`_ can serve WSGI applications directly using mod_wsgi_ and a simple Python file with the necessary configuration. This is a good option if
--- a/kallithea/bin/kallithea_cli_base.py Fri Apr 24 15:17:54 2020 +0200 +++ b/kallithea/bin/kallithea_cli_base.py Thu Apr 23 21:45:27 2020 +0200 @@ -23,7 +23,7 @@ import paste.deploy import kallithea -import kallithea.config.middleware +import kallithea.config.application # kallithea_cli is usually invoked through the 'kallithea-cli' wrapper script @@ -77,7 +77,7 @@ logging.config.fileConfig(cp, {'__file__': path_to_ini_file, 'here': os.path.dirname(path_to_ini_file)}) if config_file_initialize_app: - kallithea.config.middleware.make_app(kallithea.CONFIG.global_conf, **kallithea.CONFIG.local_conf) + kallithea.config.application.make_app(kallithea.CONFIG.global_conf, **kallithea.CONFIG.local_conf) return annotated(*args, **kwargs) return cli_command(runtime_wrapper) return annotator
--- a/kallithea/bin/kallithea_cli_db.py Fri Apr 24 15:17:54 2020 +0200 +++ b/kallithea/bin/kallithea_cli_db.py Thu Apr 23 21:45:27 2020 +0200 @@ -67,7 +67,7 @@ Session().commit() # initial repository scan - kallithea.config.middleware.make_app( + kallithea.config.application.make_app( kallithea.CONFIG.global_conf, **kallithea.CONFIG.local_conf) added, _ = kallithea.lib.utils.repo2db_mapper(kallithea.model.scm.ScmModel().repo_scan()) if added:
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/kallithea/config/application.py Thu Apr 23 21:45:27 2020 +0200 @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +"""WSGI middleware initialization for the Kallithea application.""" + +from kallithea.config.app_cfg import base_config +from kallithea.config.environment import load_environment + + +__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(global_conf, full_stack=True, **app_conf): + """ + Set up Kallithea with the settings found in the PasteDeploy configuration + file used. + + :param global_conf: The global settings for Kallithea (those + defined under the ``[DEFAULT]`` section). + :type global_conf: dict + :param full_stack: Should the whole TurboGears2 stack be set up? + :type full_stack: str or bool + :return: The Kallithea application with all the relevant middleware + loaded. + + This is the PasteDeploy factory for the Kallithea application. + + ``app_conf`` contains all the application-specific settings (those defined + under ``[app:main]``. + """ + assert app_conf.get('sqlalchemy.url') # must be called with a Kallithea .ini file, which for example must have this config option + assert global_conf.get('here') and global_conf.get('__file__') # app config should be initialized the paste way ... + return make_base_app(global_conf, full_stack=full_stack, **app_conf)
--- a/kallithea/config/middleware.py Fri Apr 24 15:17:54 2020 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -# -*- coding: utf-8 -*- -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -"""WSGI middleware initialization for the Kallithea application.""" - -from kallithea.config.app_cfg import base_config -from kallithea.config.environment import load_environment - - -__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(global_conf, full_stack=True, **app_conf): - """ - Set up Kallithea with the settings found in the PasteDeploy configuration - file used. - - :param global_conf: The global settings for Kallithea (those - defined under the ``[DEFAULT]`` section). - :type global_conf: dict - :param full_stack: Should the whole TurboGears2 stack be set up? - :type full_stack: str or bool - :return: The Kallithea application with all the relevant middleware - loaded. - - This is the PasteDeploy factory for the Kallithea application. - - ``app_conf`` contains all the application-specific settings (those defined - under ``[app:main]``. - """ - assert app_conf.get('sqlalchemy.url') # must be called with a Kallithea .ini file, which for example must have this config option - assert global_conf.get('here') and global_conf.get('__file__') # app config should be initialized the paste way ... - return make_base_app(global_conf, full_stack=full_stack, **app_conf)
--- a/kallithea/lib/hooks.py Fri Apr 24 15:17:54 2020 +0200 +++ b/kallithea/lib/hooks.py Thu Apr 23 21:45:27 2020 +0200 @@ -307,14 +307,14 @@ connect to the database. """ import paste.deploy - import kallithea.config.middleware + import kallithea.config.application extras = get_hook_environment() path_to_ini_file = extras['config'] kallithea.CONFIG = paste.deploy.appconfig('config:' + path_to_ini_file) #logging.config.fileConfig(ini_file_path) # Note: we are in a different process - don't use configured logging - kallithea.config.middleware.make_app(kallithea.CONFIG.global_conf, **kallithea.CONFIG.local_conf) + kallithea.config.application.make_app(kallithea.CONFIG.global_conf, **kallithea.CONFIG.local_conf) # fix if it's not a bare repo if repo_path.endswith(os.sep + '.git'):