configure app from object by path string
This commit is contained in:
parent
4efd450b32
commit
e978121d58
|
@ -1,6 +1,8 @@
|
|||
import os
|
||||
import types
|
||||
|
||||
import import_string
|
||||
|
||||
from sanic.exceptions import PyFileError
|
||||
|
||||
|
||||
|
@ -111,6 +113,8 @@ class Config(dict):
|
|||
|
||||
:param obj: an object holding the configuration
|
||||
"""
|
||||
if isinstance(obj, str):
|
||||
obj = import_string(obj)
|
||||
for key in dir(obj):
|
||||
if key.isupper():
|
||||
self[key] = getattr(obj, key)
|
||||
|
|
3
setup.py
3
setup.py
|
@ -4,7 +4,7 @@ Sanic
|
|||
import codecs
|
||||
import os
|
||||
import re
|
||||
from distutils.errors import DistutilsPlatformError
|
||||
|
||||
from distutils.util import strtobool
|
||||
|
||||
from setuptools import setup
|
||||
|
@ -63,6 +63,7 @@ requirements = [
|
|||
'aiofiles>=0.3.0',
|
||||
'websockets>=6.0,<7.0',
|
||||
'multidict>=4.0,<5.0',
|
||||
'import-string>=0.1.0'
|
||||
]
|
||||
if strtobool(os.environ.get("SANIC_NO_UJSON", "no")):
|
||||
print("Installing without uJSON")
|
||||
|
|
Loading…
Reference in New Issue
Block a user