Merge pull request #2824 from strikaco/attrprop
AttributeProperty tries spawning child instances of default value (#2697)
This commit is contained in:
commit
f695e624e2
1 changed files with 15 additions and 0 deletions
|
|
@ -202,6 +202,21 @@ class AttributeProperty:
|
||||||
self._lockstring = lockstring
|
self._lockstring = lockstring
|
||||||
self._autocreate = autocreate
|
self._autocreate = autocreate
|
||||||
self._key = ""
|
self._key = ""
|
||||||
|
|
||||||
|
@property
|
||||||
|
def _default(self):
|
||||||
|
"""
|
||||||
|
Tries returning a new instance of default if callable.
|
||||||
|
|
||||||
|
"""
|
||||||
|
if callable(self.__default):
|
||||||
|
return self.__default()
|
||||||
|
|
||||||
|
return self.__default
|
||||||
|
|
||||||
|
@_default.setter
|
||||||
|
def _default(self, value):
|
||||||
|
self.__default = value
|
||||||
|
|
||||||
def __set_name__(self, cls, name):
|
def __set_name__(self, cls, name):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue