extend properties must save setting only if all properties are correct
This commit is contained in:
parent
8d33fd4500
commit
a248508498
|
@ -255,12 +255,16 @@ class Property(object):
|
||||||
:param propname: a predefined or user defined property name
|
:param propname: a predefined or user defined property name
|
||||||
:type propname: string
|
:type propname: string
|
||||||
"""
|
"""
|
||||||
|
self._append(propname)
|
||||||
|
|
||||||
|
def _append(self, propname, save=True):
|
||||||
if self._opt is not None and self._opt.impl_getrequires() is not None \
|
if self._opt is not None and self._opt.impl_getrequires() is not None \
|
||||||
and propname in self._opt.impl_get_calc_properties(): # pragma: optional cover
|
and propname in self._opt.impl_get_calc_properties(): # pragma: optional cover
|
||||||
raise ValueError(_('cannot append {0} property for option {1}: '
|
raise ValueError(_('cannot append {0} property for option {1}: '
|
||||||
'this property is calculated').format(
|
'this property is calculated').format(
|
||||||
propname, self._opt.impl_getname()))
|
propname, self._opt.impl_getname()))
|
||||||
self._properties.add(propname)
|
self._properties.add(propname)
|
||||||
|
if save:
|
||||||
self._setting._setproperties(self._properties, self._path)
|
self._setting._setproperties(self._properties, self._path)
|
||||||
|
|
||||||
def remove(self, propname):
|
def remove(self, propname):
|
||||||
|
@ -280,7 +284,8 @@ class Property(object):
|
||||||
:type propnames: iterable of string
|
:type propnames: iterable of string
|
||||||
"""
|
"""
|
||||||
for propname in propnames:
|
for propname in propnames:
|
||||||
self.append(propname)
|
self._append(propname, save=False)
|
||||||
|
self._setting._setproperties(self._properties, self._path)
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
"""resets the properties (does not **clear** the properties,
|
"""resets the properties (does not **clear** the properties,
|
||||||
|
|
Loading…
Reference in New Issue