feat: base get_sysconfig可返回默认参数
This commit is contained in:
parent
89af31a383
commit
3c99770477
|
@ -341,7 +341,7 @@ LOGGING = {
|
||||||
##### 加载客户可自定义配置并提供操作方法 #####
|
##### 加载客户可自定义配置并提供操作方法 #####
|
||||||
SYS_JSON_PATH = os.path.join(BASE_DIR, 'server/conf.json')
|
SYS_JSON_PATH = os.path.join(BASE_DIR, 'server/conf.json')
|
||||||
|
|
||||||
def get_sysconfig(key='', reload=False):
|
def get_sysconfig(key='', default='raise_error', reload=False):
|
||||||
"""获取系统配置可指定key字符串
|
"""获取系统配置可指定key字符串
|
||||||
"""
|
"""
|
||||||
config = cache.get('system_config', None)
|
config = cache.get('system_config', None)
|
||||||
|
@ -355,7 +355,13 @@ def get_sysconfig(key='', reload=False):
|
||||||
if key:
|
if key:
|
||||||
k_l = key.split('.')
|
k_l = key.split('.')
|
||||||
for k in k_l:
|
for k in k_l:
|
||||||
config = config[k]
|
try:
|
||||||
|
config = config[k]
|
||||||
|
except KeyError:
|
||||||
|
if default == 'raise_error':
|
||||||
|
raise
|
||||||
|
else:
|
||||||
|
return default
|
||||||
return config
|
return config
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue