force_store_value for follower
This commit is contained in:
parent
7325f6e12f
commit
c5d8e0055b
|
@ -76,9 +76,7 @@ class Leadership(OptionDescription):
|
||||||
self.impl_get_display_name()))
|
self.impl_get_display_name()))
|
||||||
if idx != 0:
|
if idx != 0:
|
||||||
# remove empty property for follower
|
# remove empty property for follower
|
||||||
child_properties = list(child._properties)
|
child._properties = frozenset(child._properties - {'empty', 'unique'})
|
||||||
child_properties.remove('empty')
|
|
||||||
child._properties = frozenset(child_properties)
|
|
||||||
followers.append(child)
|
followers.append(child)
|
||||||
child._add_dependency(self)
|
child._add_dependency(self)
|
||||||
child._leadership = weakref.ref(self)
|
child._leadership = weakref.ref(self)
|
||||||
|
@ -129,6 +127,33 @@ class Leadership(OptionDescription):
|
||||||
values.reset(soption_bag,
|
values.reset(soption_bag,
|
||||||
_commit=_commit)
|
_commit=_commit)
|
||||||
|
|
||||||
|
def follower_force_store_value(self,
|
||||||
|
values,
|
||||||
|
value,
|
||||||
|
option_bag,
|
||||||
|
owner,
|
||||||
|
_commit) -> None:
|
||||||
|
settings = option_bag.config_bag.context.cfgimpl_get_settings()
|
||||||
|
if value:
|
||||||
|
rgevalue = range(len(value))
|
||||||
|
for follower in self.get_children(option_bag.config_bag):
|
||||||
|
foption_bag = OptionBag()
|
||||||
|
foption_bag.set_option(follower,
|
||||||
|
follower.impl_getpath(),
|
||||||
|
None,
|
||||||
|
option_bag.config_bag)
|
||||||
|
if 'force_store_value' in settings.getproperties(foption_bag):
|
||||||
|
for index in rgevalue:
|
||||||
|
foption_bag = OptionBag()
|
||||||
|
foption_bag.set_option(follower,
|
||||||
|
follower.impl_getpath(),
|
||||||
|
index,
|
||||||
|
option_bag.config_bag)
|
||||||
|
values._setvalue(foption_bag,
|
||||||
|
values.getvalue(foption_bag),
|
||||||
|
owner,
|
||||||
|
commit=False)
|
||||||
|
|
||||||
def pop(self,
|
def pop(self,
|
||||||
values: Values,
|
values: Values,
|
||||||
index: int,
|
index: int,
|
||||||
|
|
|
@ -80,11 +80,6 @@ class CacheOptionDescription(BaseOption):
|
||||||
properties = option.impl_getproperties()
|
properties = option.impl_getproperties()
|
||||||
if 'force_store_value' in properties:
|
if 'force_store_value' in properties:
|
||||||
if __debug__:
|
if __debug__:
|
||||||
if option.impl_is_follower():
|
|
||||||
# problem with index
|
|
||||||
raise ConfigError(_('the follower "{0}" cannot have '
|
|
||||||
'"force_store_value" property').format(
|
|
||||||
option.impl_get_display_name()))
|
|
||||||
if option.issubdyn():
|
if option.issubdyn():
|
||||||
raise ConfigError(_('the dynoption "{0}" cannot have '
|
raise ConfigError(_('the dynoption "{0}" cannot have '
|
||||||
'"force_store_value" property').format(
|
'"force_store_value" property').format(
|
||||||
|
@ -125,6 +120,28 @@ class CacheOptionDescription(BaseOption):
|
||||||
values = config_bag.context.cfgimpl_get_values()
|
values = config_bag.context.cfgimpl_get_values()
|
||||||
for subpath, option in self._cache_force_store_values:
|
for subpath, option in self._cache_force_store_values:
|
||||||
if not values._p_.hasvalue(subpath):
|
if not values._p_.hasvalue(subpath):
|
||||||
|
if option.impl_is_follower():
|
||||||
|
option_bag = OptionBag()
|
||||||
|
leader = option.impl_get_leadership().get_leader()
|
||||||
|
option_bag.set_option(leader,
|
||||||
|
leader.impl_getpath(),
|
||||||
|
None,
|
||||||
|
config_bag)
|
||||||
|
option_bag.properties = frozenset()
|
||||||
|
follower_len = len(values.getvalue(option_bag))
|
||||||
|
for index in range(follower_len):
|
||||||
|
option_bag = OptionBag()
|
||||||
|
option_bag.set_option(option,
|
||||||
|
subpath,
|
||||||
|
index,
|
||||||
|
config_bag)
|
||||||
|
option_bag.properties = frozenset()
|
||||||
|
values._p_.setvalue(subpath,
|
||||||
|
values.getvalue(option_bag),
|
||||||
|
owners.forced,
|
||||||
|
index,
|
||||||
|
False)
|
||||||
|
else:
|
||||||
option_bag = OptionBag()
|
option_bag = OptionBag()
|
||||||
option_bag.set_option(option,
|
option_bag.set_option(option,
|
||||||
subpath,
|
subpath,
|
||||||
|
|
Loading…
Reference in New Issue