copy value before store it
This commit is contained in:
parent
cdcb155acc
commit
9cc4518087
1 changed files with 9 additions and 11 deletions
|
@ -90,7 +90,8 @@ class Values(object):
|
||||||
check_error=False)
|
check_error=False)
|
||||||
if isinstance(value, list):
|
if isinstance(value, list):
|
||||||
# return a copy, so value cannot be modified
|
# return a copy, so value cannot be modified
|
||||||
return value.copy()
|
from copy import copy
|
||||||
|
value = copy(value)
|
||||||
# and return it
|
# and return it
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
@ -177,12 +178,8 @@ class Values(object):
|
||||||
return value
|
return value
|
||||||
|
|
||||||
# now try to get default value:
|
# now try to get default value:
|
||||||
value = option_bag.option.impl_getdefault()
|
value = self.calc_value(option_bag,
|
||||||
|
option_bag.option.impl_getdefault())
|
||||||
# - if option is a submulti, return a list a list
|
|
||||||
# - if option is a multi, return a list
|
|
||||||
# - default value
|
|
||||||
value = self.calc_value(option_bag, value)
|
|
||||||
if option_bag.option.impl_is_multi() and option_bag.index is not None and isinstance(value, (list, tuple)):
|
if option_bag.option.impl_is_multi() and option_bag.index is not None and isinstance(value, (list, tuple)):
|
||||||
# if index, must return good value for this index
|
# if index, must return good value for this index
|
||||||
if len(value) > option_bag.index:
|
if len(value) > option_bag.index:
|
||||||
|
@ -190,7 +187,8 @@ class Values(object):
|
||||||
else:
|
else:
|
||||||
# no value for this index, retrieve default multi value
|
# no value for this index, retrieve default multi value
|
||||||
# default_multi is already a list for submulti
|
# default_multi is already a list for submulti
|
||||||
value = self.calc_value(option_bag, option_bag.option.impl_getdefault_multi())
|
value = self.calc_value(option_bag,
|
||||||
|
option_bag.option.impl_getdefault_multi())
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def calculate_reset_cache(self, option_bag, value):
|
def calculate_reset_cache(self, option_bag, value):
|
||||||
|
@ -285,6 +283,9 @@ class Values(object):
|
||||||
self.setvalue_validation(value,
|
self.setvalue_validation(value,
|
||||||
option_bag)
|
option_bag)
|
||||||
|
|
||||||
|
if isinstance(value, list):
|
||||||
|
# copy
|
||||||
|
value = value.copy()
|
||||||
self._setvalue(option_bag,
|
self._setvalue(option_bag,
|
||||||
value,
|
value,
|
||||||
owner,
|
owner,
|
||||||
|
@ -334,9 +335,6 @@ class Values(object):
|
||||||
owner,
|
owner,
|
||||||
commit=True):
|
commit=True):
|
||||||
option_bag.config_bag.context.cfgimpl_reset_cache(option_bag)
|
option_bag.config_bag.context.cfgimpl_reset_cache(option_bag)
|
||||||
if isinstance(value, list):
|
|
||||||
# copy
|
|
||||||
value = value.copy()
|
|
||||||
self._p_.setvalue(option_bag.path,
|
self._p_.setvalue(option_bag.path,
|
||||||
value,
|
value,
|
||||||
owner,
|
owner,
|
||||||
|
|
Loading…
Reference in a new issue