[lib.domain] fix mounting domains with environment variable
This commit is contained in:
parent
cdd2214043
commit
061c966072
|
@ -230,19 +230,19 @@ def d_domains(config) -> Dict[str, ModuleType]:
|
||||||
|
|
||||||
dict[str, ModuleType]
|
dict[str, ModuleType]
|
||||||
"""
|
"""
|
||||||
if os.environ.get('HALFAPI_DOMAIN_NAME') and os.environ.get('HALFAPI_DOMAIN_MODULE', '.routers'):
|
|
||||||
config['domains'] = {
|
|
||||||
os.environ.get('HALFAPI_DOMAIN_NAME'): os.environ.get('HALFAPI_DOMAIN_MODULE')
|
|
||||||
}
|
|
||||||
|
|
||||||
if not 'domains' in config:
|
domains = {}
|
||||||
return {}
|
|
||||||
|
if os.environ.get('HALFAPI_DOMAIN_NAME') and os.environ.get('HALFAPI_DOMAIN_MODULE', '.routers'):
|
||||||
|
domains[os.environ.get('HALFAPI_DOMAIN_NAME')] = os.environ.get('HALFAPI_DOMAIN_MODULE')
|
||||||
|
elif 'domains' in config:
|
||||||
|
domains = dict(config['domains'].items())
|
||||||
|
|
||||||
try:
|
try:
|
||||||
sys.path.append('.')
|
sys.path.append('.')
|
||||||
return {
|
return {
|
||||||
domain: importlib.import_module(''.join((domain, module)))
|
domain: importlib.import_module(''.join((domain, module)))
|
||||||
for domain, module in config['domains'].items()
|
for domain, module in domains.items()
|
||||||
}
|
}
|
||||||
except ImportError as exc:
|
except ImportError as exc:
|
||||||
logger.error('Could not load a domain : %s', exc)
|
logger.error('Could not load a domain : %s', exc)
|
||||||
|
|
Loading…
Reference in New Issue