From 2319ecde61da168df47131ffaa69af738d97a377 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Thu, 25 Apr 2024 16:57:00 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20base=20get=5Fsysconfig=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E4=BC=A0=E5=85=A5=E5=85=B7=E4=BD=93key=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/settings.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server/settings.py b/server/settings.py index 6d1097bf..2167f8d8 100755 --- a/server/settings.py +++ b/server/settings.py @@ -339,7 +339,9 @@ LOGGING = { ##### 加载客户可自定义配置并提供操作方法 ##### SYS_JSON_PATH = os.path.join(BASE_DIR, 'server/conf.json') -def get_sysconfig(reload=False): +def get_sysconfig(key='', reload=False): + """获取系统配置可指定key字符串 + """ config = cache.get('system_config', None) if config is None or reload: # 读取配置文件 @@ -349,6 +351,10 @@ def get_sysconfig(reload=False): config = json.loads(f.read()) cache.set('system_config', config) return config + if key: + k_l = key.split('.') + for k in k_l: + config = config[k] return config