private method _get_multitype()
This commit is contained in:
parent
7b4f3b5d36
commit
77633c84ce
|
@ -38,19 +38,23 @@ class Values(object):
|
||||||
self.slaves = {}
|
self.slaves = {}
|
||||||
self.context = context
|
self.context = context
|
||||||
|
|
||||||
|
def _get_multitype(self):
|
||||||
|
if opt in self.slaves:
|
||||||
|
# slave
|
||||||
|
multitype = multitypes.slave
|
||||||
|
elif opt in self.masters:
|
||||||
|
# master
|
||||||
|
multitype = multitypes.master
|
||||||
|
# FIXME : default value for a multi, we shall work on groups
|
||||||
|
else:
|
||||||
|
multitype = multitypes.default
|
||||||
|
return multitype
|
||||||
|
|
||||||
def _get_value(self, opt):
|
def _get_value(self, opt):
|
||||||
"special case for the multis: they never return None"
|
"special case for the multis: they never return None"
|
||||||
if opt not in self.values:
|
if opt not in self.values:
|
||||||
if opt.is_multi():
|
if opt.is_multi():
|
||||||
if opt in self.slaves:
|
multitype = self._get_multitype()
|
||||||
# slave
|
|
||||||
multitype = multitypes.slave
|
|
||||||
elif opt in self.masters:
|
|
||||||
# master
|
|
||||||
multitype = multitypes.master
|
|
||||||
# FIXME : default value for a multi, we shall work on groups
|
|
||||||
else:
|
|
||||||
multitype = multitypes.default
|
|
||||||
return Multi(opt.getdefault(), self.context, opt, multitype)
|
return Multi(opt.getdefault(), self.context, opt, multitype)
|
||||||
else:
|
else:
|
||||||
return opt.getdefault()
|
return opt.getdefault()
|
||||||
|
@ -99,7 +103,8 @@ class Values(object):
|
||||||
_result = [result]
|
_result = [result]
|
||||||
else:
|
else:
|
||||||
_result = result
|
_result = result
|
||||||
return Multi(_result, self.context, opt)
|
multitype = self._get_multitype()
|
||||||
|
return Multi(_result, self.context, opt, multitype)
|
||||||
|
|
||||||
def __getitem__(self, opt):
|
def __getitem__(self, opt):
|
||||||
# options with callbacks
|
# options with callbacks
|
||||||
|
@ -107,7 +112,7 @@ class Values(object):
|
||||||
if opt.has_callback():
|
if opt.has_callback():
|
||||||
if (not opt.is_frozen() or \
|
if (not opt.is_frozen() or \
|
||||||
not opt.is_forced_on_freeze()) and \
|
not opt.is_forced_on_freeze()) and \
|
||||||
not opt.is_default_owner(self):
|
not opt.is_default_owner(self.context):
|
||||||
return self._get_value(opt)
|
return self._get_value(opt)
|
||||||
try:
|
try:
|
||||||
result = opt.getcallback_value(
|
result = opt.getcallback_value(
|
||||||
|
@ -116,7 +121,7 @@ class Values(object):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if opt.is_multi():
|
if opt.is_multi():
|
||||||
value = fill_multi(opt, result)
|
value = self.fill_multi(opt, result)
|
||||||
else:
|
else:
|
||||||
# this result **shall not** be a list
|
# this result **shall not** be a list
|
||||||
if isinstance(result, list):
|
if isinstance(result, list):
|
||||||
|
|
Loading…
Reference in New Issue