mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-01-11 00:31:56 -06:00
install: Run all validators at once.
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
This commit is contained in:
parent
cac756b87d
commit
2c5a662fd8
@ -118,16 +118,6 @@ class KnobBase(PropertyBase):
|
||||
def __init__(self, outer):
|
||||
self.outer = outer
|
||||
|
||||
def __set__(self, obj, value):
|
||||
try:
|
||||
self.validate(value)
|
||||
except KnobValueError:
|
||||
raise
|
||||
except ValueError as e:
|
||||
raise KnobValueError(self.__outer_name__, str(e))
|
||||
|
||||
super(KnobBase, self).__set__(obj, value)
|
||||
|
||||
def validate(self, value):
|
||||
pass
|
||||
|
||||
@ -253,8 +243,25 @@ class Configurable(six.with_metaclass(abc.ABCMeta, object)):
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
prop = prop_cls(self)
|
||||
prop.__set__(self, value)
|
||||
setattr(self, name, value)
|
||||
|
||||
for owner_cls, name in cls.knobs():
|
||||
if name.startswith('_'):
|
||||
continue
|
||||
if not isinstance(self, owner_cls):
|
||||
continue
|
||||
value = getattr(self, name, None)
|
||||
if value is None:
|
||||
continue
|
||||
|
||||
prop_cls = getattr(owner_cls, name)
|
||||
prop = prop_cls(self)
|
||||
try:
|
||||
prop.validate(value)
|
||||
except KnobValueError:
|
||||
raise
|
||||
except ValueError as e:
|
||||
raise KnobValueError(name, str(e))
|
||||
|
||||
if kwargs:
|
||||
extra = sorted(kwargs)
|
||||
|
Loading…
Reference in New Issue
Block a user