can set owner for a slave

This commit is contained in:
2016-01-25 16:22:28 +01:00
parent 8a21d49948
commit 51d14f30a4
3 changed files with 30 additions and 9 deletions

View File

@ -115,10 +115,12 @@ class Values(Cache):
idx = self._values[0].index(path)
if isinstance(self._values[3][idx], list):
if index is None:
raise ValueError('list but no index')
owner = list(self._values[3][idx])[index] = owner
raise ValueError('Slave need index to set owner')
towner = list(self._values[3][idx])
towner[index] = owner
owner = towner
elif index is not None:
raise ValueError('index set but not a list')
raise ValueError('Only slave option needs index to set owner')
lst = list(self._values[3])
lst[idx] = owner
values = list(self._values)

View File

@ -506,7 +506,7 @@ class Values(object):
only_default=only_default, index=index)
return owner
def setowner(self, opt, owner):
def setowner(self, opt, owner, index=None):
"""
sets a owner to an option
@ -523,10 +523,11 @@ class Values(object):
props = self._getcontext().cfgimpl_get_settings().validate_properties(opt,
False,
True,
path)
path,
index=index)
if props:
raise props
self._p_.setowner(path, owner)
self._p_.setowner(path, owner, index=index)
def is_default_owner(self, opt, validate_properties=True,
validate_meta=True, index=None):
@ -752,7 +753,8 @@ class Multi(list):
True, False, True,
index=index)
def append(self, value=undefined, force=False, setitem=True, validate=True):
def append(self, value=undefined, force=False, setitem=True, validate=True,
force_permissive=False):
"""the list value can be updated (appened)
only if the option is a master
"""
@ -769,7 +771,8 @@ class Multi(list):
if 'validator' in setting_properties:
fake_context = context._gen_fake_values()
fake_multi = fake_context.cfgimpl_get_values()._get_cached_value(
self.opt, path=self.path, validate=False)
self.opt, path=self.path, validate=False,
force_permissive=force_permissive)
fake_multi.append(value, validate=False, force=True)
self._validate(value, fake_context, index, True)
if not '_index' in self.__slots__ and self.opt.impl_is_submulti():