From d733b070b0be4f195eb53b69a2a6379d4041404b Mon Sep 17 00:00:00 2001 From: cuiweizhi <560397@gree.com.cn> Date: Sat, 11 Nov 2023 14:32:51 +0800 Subject: [PATCH] Update project --- application/__init__.py | 5 +++-- application/common/__init__.py | 2 +- application/common/{config.py => universal.py} | 10 +++++----- application/libs/helper/config.py | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) rename application/common/{config.py => universal.py} (75%) diff --git a/application/__init__.py b/application/__init__.py index 2e2372a..ac528a7 100644 --- a/application/__init__.py +++ b/application/__init__.py @@ -18,7 +18,7 @@ from application.extensions import init_plugs from application.views import init_views from application.script import init_script from application.utils import make_celery -from application.common import config +from application.common import global_config as gc def create_app() -> Flask: @@ -39,7 +39,8 @@ def create_app() -> Flask: init_plugs(app) # Set universal config - config.universal = app.config + # 将 app.config 的内容复制到全局对象 + gc.config = app.config.copy() # Register the routes that this application will respond to. # This includes both the route URLs and the handlers for each route. diff --git a/application/common/__init__.py b/application/common/__init__.py index 52f613c..3d9cc1a 100644 --- a/application/common/__init__.py +++ b/application/common/__init__.py @@ -10,4 +10,4 @@ # @Description : """ -from .config import Config +from .universal import global_config diff --git a/application/common/config.py b/application/common/universal.py similarity index 75% rename from application/common/config.py rename to application/common/universal.py index ce06588..5379ab8 100644 --- a/application/common/config.py +++ b/application/common/universal.py @@ -6,17 +6,17 @@ # @Author : StudentCWZ # @Email : StudentCWZ@outlook.com # @Date : 2023/11/11 14:11 -# @File : config.py +# @File : universal.py # @Description : """ -# config.py -class Config: +# universal.py +class GlobalConfig: """Configuration for the application.""" def __init__(self): - self.universal = None + self.config = {} # This creates a global instance of the Config class -config = Config() +global_config = GlobalConfig() diff --git a/application/libs/helper/config.py b/application/libs/helper/config.py index 6b463d5..862c9e3 100644 --- a/application/libs/helper/config.py +++ b/application/libs/helper/config.py @@ -6,7 +6,7 @@ # @Author : StudentCWZ # @Email : StudentCWZ@outlook.com # @Date : 2023/11/3 19:43 -# @File : config.py +# @File : universal.py # @Description : """ -- GitLab