def from_object(self, obj):
"""Updates the values from the given object. An object can be of one
of the following two types:
- a string: in this case the object with that name will be imported
- an actual object reference: that object is used directly
:param obj: an import name or object
"""
string_types = (str,)
if isinstance(obj, string_types):
# github.com/pallets/werkzeug/blob/master/werkzeug/utils.py+L399
# obj = import_string(obj)
obj = importlib.import_module(obj)
for key in dir(obj):
if key.isupper():
self[key] = getattr(obj, key)
评论列表
文章目录