type shall not be a list
authorgwen <gremond@cadoles.com>
Tue, 26 Feb 2013 15:58:44 +0000 (16:58 +0100)
committergwen <gremond@cadoles.com>
Tue, 26 Feb 2013 15:58:44 +0000 (16:58 +0100)
tiramisu/value.py

index d62d558..282c996 100644 (file)
@@ -79,6 +79,8 @@ class Values(object):
     def get_previous_value(self, opt):
         if opt in self.previous_values:
             prec_value = self.previous_values[opt]
+        elif opt.is_multi():
+            prec_value = []
         else:
             prec_value = None
         return prec_value
@@ -180,10 +182,16 @@ class Values(object):
                    raise MultiTypeError("invalid len for the slave: {0}"
                     " which has {1} as master".format(opt._name,
                                                       self.slaves[opt]._name))
+        elif opt.is_multi():
+            if not isinstance(value, Multi):
+                value = Multi(value, self.context, opt, multitypes.default)
         self.setitem(opt, value)
 
     def setitem(self, opt, value):
         self.set_previous_value(opt)
+        if type(value) == list:
+            raise MultiTypeError("the type of the value {0} which is multi shall "
+                                 "be Multi and not list".format(str(value)))
         self.values[opt] = value
         self.setowner(opt, self.context._cfgimpl_settings.getowner())