From 447c175b6a50291a26241f298e62183fe89517b0 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Tue, 16 Apr 2013 09:45:42 +0200 Subject: [PATCH] Add "force_store_value" property. If set, store, for example, calculated value as owner values. So calculated value are calculate only one time. --- tiramisu/value.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tiramisu/value.py b/tiramisu/value.py index e8c6f25..be0fe6c 100644 --- a/tiramisu/value.py +++ b/tiramisu/value.py @@ -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)