extend properties must save setting only if all properties are correct
authorEmmanuel Garette <egarette@cadoles.com>
Sun, 1 Nov 2015 10:12:27 +0000 (11:12 +0100)
committerEmmanuel Garette <egarette@cadoles.com>
Sun, 1 Nov 2015 10:12:27 +0000 (11:12 +0100)
tiramisu/setting.py

index 39c4152..746608c 100644 (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,