From 6a2161ece3c6ba3ce67afeaff2f3a4f9d5ee763d Mon Sep 17 00:00:00 2001 From: Marco Donadoni Date: Wed, 3 Jul 2024 15:32:56 +0200 Subject: [PATCH] wip: remove some flask warnings (to be tested) --- Dockerfile | 2 +- reana_server/ext.py | 25 +++++++++++-------------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/Dockerfile b/Dockerfile index 88d8be46..eec2c299 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # This file is part of REANA. -# Copyright (C) 2017, 2018, 2019, 2020, 2021, 2022, 2023 CERN. +# Copyright (C) 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024 CERN. # # REANA is free software; you can redistribute it and/or modify it # under the terms of the MIT License; see LICENSE file for more details. diff --git a/reana_server/ext.py b/reana_server/ext.py index d1ed5967..ef68eaf9 100644 --- a/reana_server/ext.py +++ b/reana_server/ext.py @@ -16,7 +16,15 @@ from reana_commons.config import REANA_LOG_FORMAT, REANA_LOG_LEVEL from werkzeug.exceptions import UnprocessableEntity +from invenio_oauthclient.signals import account_info_received +from flask_security.signals import user_registered + + from reana_server import config +from reana_server.utils import ( + _create_and_associate_local_user, + _create_and_associate_oauth_user, +) def handle_rate_limit_error(error: RateLimitExceeded): @@ -69,6 +77,9 @@ def init_app(self, app): self.init_config(app) self.init_error_handlers(app) + account_info_received.connect(_create_and_associate_oauth_user) + user_registered.connect(_create_and_associate_local_user) + @app.teardown_appcontext def shutdown_reana_db_session(response_or_exc): """Close session on app teardown.""" @@ -79,20 +90,6 @@ def shutdown_reana_db_session(response_or_exc): invenio_db.session.remove() return response_or_exc - @app.before_first_request - def connect_signals(): - """Connect OAuthClient signals.""" - from invenio_oauthclient.signals import account_info_received - from flask_security.signals import user_registered - - from .utils import ( - _create_and_associate_local_user, - _create_and_associate_oauth_user, - ) - - account_info_received.connect(_create_and_associate_oauth_user) - user_registered.connect(_create_and_associate_local_user) - def init_config(self, app): """Initialize configuration.""" for k in dir(config):