extend properties must save setting only if all properties are correct

This commit is contained in:
Emmanuel Garette 2015-11-01 11:12:27 +01:00
parent 8d33fd4500
commit a248508498

View File

@ -255,13 +255,17 @@ class Property(object):
:param propname: a predefined or user defined property name
: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 \
and propname in self._opt.impl_get_calc_properties(): # pragma: optional cover
raise ValueError(_('cannot append {0} property for option {1}: '
'this property is calculated').format(
propname, self._opt.impl_getname()))
self._properties.add(propname)
self._setting._setproperties(self._properties, self._path)
if save:
self._setting._setproperties(self._properties, self._path)
def remove(self, propname):
"""Removes a property named propname
@ -280,7 +284,8 @@ class Property(object):
:type propnames: iterable of string
"""
for propname in propnames:
self.append(propname)
self._append(propname, save=False)
self._setting._setproperties(self._properties, self._path)
def reset(self):
"""resets the properties (does not **clear** the properties,