experimental persistent mixin

- still contains changes in mouduls/params ...
This commit is contained in:
2021-06-04 12:19:04 +02:00
parent 1409959f53
commit fe5a2caac7
6 changed files with 483 additions and 308 deletions

View File

@ -39,10 +39,6 @@ class Accessible(HasProperties):
kwds = None # is a dict if it might be used as Override
def __init__(self, **kwds):
super().__init__()
self.init(kwds)
def init(self, kwds):
# do not use self.propertyValues.update here, as no invalid values should be
# assigned to properties, even not before checkProperties
@ -153,6 +149,9 @@ class Parameter(Accessible):
handler = Property(
'[internal] overload the standard read and write functions', ValueType(),
export=False, default=None, settable=False)
persistent = Property(
'[internal] persistent setting', BoolType(),
export=False, default=False)
initwrite = Property(
'''[internal] write this parameter on initialization
@ -165,7 +164,7 @@ class Parameter(Accessible):
readerror = None
def __init__(self, description=None, datatype=None, inherit=True, *, unit=None, constant=None, **kwds):
super().__init__(**kwds)
super().__init__()
if datatype is not None:
if not isinstance(datatype, DataType):
if isinstance(datatype, type) and issubclass(datatype, DataType):
@ -178,6 +177,8 @@ class Parameter(Accessible):
if 'default' in kwds:
self.default = datatype(kwds['default'])
self.init(kwds) # datatype must be defined before we can treat dataset properties like fmtstr or unit
if description is not None:
self.description = inspect.cleandoc(description)
@ -313,7 +314,8 @@ class Command(Accessible):
func = None
def __init__(self, argument=False, *, result=None, inherit=True, **kwds):
super().__init__(**kwds)
super().__init__()
self.init(kwds)
if result or kwds or isinstance(argument, DataType) or not callable(argument):
# normal case
if argument is False and result: