提交 cfdacf50 authored 作者: Frederic's avatar Frederic

Allow to give a callable as a default value.

We call it only if the user didn't provide a value.
上级 1806b028
......@@ -253,11 +253,13 @@ class ConfigParam(object):
# invalid and causes a crash or has unwanted side effects.
def __get__(self, *args):
#print "GETTING PARAM", self.fullname, self, args
if not hasattr(self, 'val'):
try:
val_str = fetch_val_for_key(self.fullname)
except KeyError:
if callable(self.default):
val_str = self.default()
else:
val_str = self.default
self.__set__(None, val_str)
#print "RVAL", self.val
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论