type shall not be a list

This commit is contained in:
gwen 2013-02-26 16:58:44 +01:00
parent 151bc83ba5
commit e515ec145d
1 changed files with 8 additions and 0 deletions

View 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())