From 68548f4b64c96c249e076a8aaad7e227df9b6431 Mon Sep 17 00:00:00 2001 From: Bjarke Madsen <bjarke@nordu.net> Date: Tue, 11 Jul 2023 16:26:14 +0200 Subject: [PATCH] perform workaround for sphinx calling _create_app with no config --- compendium_v2/__init__.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/compendium_v2/__init__.py b/compendium_v2/__init__.py index 7fa85481..f30107f0 100644 --- a/compendium_v2/__init__.py +++ b/compendium_v2/__init__.py @@ -37,15 +37,6 @@ def _create_app(app_config) -> Flask: app = Flask(__name__) CORS(app) - app.config['CONFIG_PARAMS'] = app_config - app.config['SECRET_KEY'] = app_config['SECRET_KEY'] - app.config['SESSION_COOKIE_SECURE'] = True - if 'oidc' not in app_config: - app.config['LOGIN_DISABLED'] = True - logger.info('No OIDC configuration found, authentication disabled') - else: - logger.info('OIDC configuration found, authentication will be enabled') - from compendium_v2.routes import default app.register_blueprint(default.routes, url_prefix='/') @@ -55,6 +46,19 @@ def _create_app(app_config) -> Flask: from compendium_v2.routes import api app.register_blueprint(api.routes, url_prefix='/api') + if not app_config: + # workaround for sphinx causing app to be created, but not loading a config + return app + + app.config['CONFIG_PARAMS'] = app_config + app.config['SECRET_KEY'] = app_config['SECRET_KEY'] + app.config['SESSION_COOKIE_SECURE'] = True + if 'oidc' not in app_config: + app.config['LOGIN_DISABLED'] = True + logger.info('No OIDC configuration found, authentication disabled') + else: + logger.info('OIDC configuration found, authentication will be enabled') + return app -- GitLab