Add "force_store_value" property. If set, store, for example, calculated value as...
authorEmmanuel Garette <egarette@cadoles.com>
Tue, 16 Apr 2013 07:45:42 +0000 (09:45 +0200)
committerEmmanuel Garette <egarette@cadoles.com>
Tue, 16 Apr 2013 07:45:42 +0000 (09:45 +0200)
So calculated value are calculate only one time.

tiramisu/value.py

index e8c6f25..be0fe6c 100644 (file)
@@ -146,6 +146,9 @@ class Values(object):
         if validate and not opt.validate(value, self.context, setting.has_property('validator')):
             raise ValueError(_('invalid calculated value returned'
                              ' for option {0}: {1}').format(opt._name, value))
+        if self.is_default_owner(opt) and \
+                setting.has_property('auto_store_value', opt, False):
+            self.setitem(opt, value)
         return value
 
     def __setitem__(self, opt, value):
@@ -245,8 +248,8 @@ class Multi(list):
     def _validate(self, value):
         if value is not None and not self.opt._validate(value):
             raise ValueError(_("invalid value {0} "
-                              "for option {1}").format(str(value),
-                                                       self.opt._name))
+                             "for option {1}").format(str(value),
+                                                      self.opt._name))
 
     def pop(self, key, force=False):
         """the list value can be updated (poped)