changeset 8548:27d9ca0c8381

tg: use FullStackApplicationConfigurator instead of deprecated setup_tg_wsgi_app and AppConfig
author Mads Kiilerich <mads@kiilerich.com>
date Fri, 24 Apr 2020 13:17:00 +0200
parents 0619fe53ff6d
children d757635af3c2
files kallithea/config/app_cfg.py kallithea/config/application.py
diffstat 2 files changed, 8 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/config/app_cfg.py	Thu Apr 23 22:40:27 2020 +0200
+++ b/kallithea/config/app_cfg.py	Fri Apr 24 13:17:00 2020 +0200
@@ -28,7 +28,7 @@
 from alembic.migration import MigrationContext
 from alembic.script.base import ScriptDirectory
 from sqlalchemy import create_engine
-from tg.configuration import AppConfig
+from tg import FullStackApplicationConfigurator
 
 import kallithea.lib.locale
 import kallithea.model.base
@@ -47,7 +47,9 @@
 log = logging.getLogger(__name__)
 
 
-base_config = AppConfig(**{
+base_config = FullStackApplicationConfigurator()
+
+base_config.update_blueprint({
     'package': kallithea,
 
     # Rendering Engines Configuration
@@ -189,4 +191,4 @@
     return app
 
 
-tg.hooks.register('before_config', setup_application)
+tg.hooks.register('before_wsgi_middlewares', setup_application)
--- a/kallithea/config/application.py	Thu Apr 23 22:40:27 2020 +0200
+++ b/kallithea/config/application.py	Fri Apr 24 13:17:00 2020 +0200
@@ -18,22 +18,14 @@
 
 __all__ = ['make_app']
 
-load_environment = base_config.make_load_environment()
-# 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):
+def make_app(global_conf, **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.
 
@@ -44,4 +36,5 @@
     """
     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)
+
+    return base_config.make_wsgi_app(global_conf, app_conf, wrap_app=None)