better reset_cache

This commit is contained in:
Emmanuel Garette 2018-04-03 21:15:58 +02:00
parent dc84608348
commit 13ec51f468
3 changed files with 19 additions and 27 deletions

View File

@ -92,24 +92,17 @@ class SubConfig(object):
opt, opt,
path): path):
tresetted_opts = copy(resetted_opts)
opt.reset_cache(opt, opt.reset_cache(opt,
path, path,
values, values,
'values',
tresetted_opts)
tresetted_opts = copy(resetted_opts)
opt.reset_cache(opt,
path,
settings, settings,
'settings', resetted_opts)
tresetted_opts)
resetted_opts.extend(tresetted_opts)
for woption in opt._get_dependencies(self): for woption in opt._get_dependencies(self):
option = woption() option = woption()
if option in resetted_opts:
continue
option_path = option.impl_getpath(self) option_path = option.impl_getpath(self)
print(option_path, resetted_opts)
if option_path in resetted_opts:
continue
self.reset_one_option_cache(values, self.reset_one_option_cache(values,
settings, settings,
resetted_opts, resetted_opts,
@ -135,7 +128,7 @@ class SubConfig(object):
settings = context.cfgimpl_get_settings() settings = context.cfgimpl_get_settings()
if not None in (opt, path): if not None in (opt, path):
if opt not in resetted_opts: if path not in resetted_opts:
self.reset_one_option_cache(values, self.reset_one_option_cache(values,
settings, settings,
resetted_opts, resetted_opts,

View File

@ -498,17 +498,16 @@ class BaseOption(Base):
def reset_cache(self, def reset_cache(self,
opt, opt,
path, path,
obj, values,
type_, settings,
resetted_opts): resetted_opts):
if opt in resetted_opts: if opt in resetted_opts:
return return
if not type_ == 'values' or not opt.impl_is_optiondescription(): settings._p_.delcache(path)
if type_ != 'permissives': settings._pp_.delcache(path)
obj._p_.delcache(path) if not opt.impl_is_optiondescription():
if type_ in ['settings', 'permissives']: values._p_.delcache(path)
obj._pp_.delcache(path) resetted_opts.append(path)
resetted_opts.append(opt)
def impl_is_symlinkoption(self): def impl_is_symlinkoption(self):
return False return False

View File

@ -146,24 +146,24 @@ class MasterSlaves(OptionDescription):
def reset_cache(self, def reset_cache(self,
opt, opt,
path, path,
obj, values,
type_, settings,
resetted_opts): resetted_opts):
context = obj._getcontext() context = values._getcontext()
#FIXME pb avec dyn, devrait etre une option #FIXME pb avec dyn, devrait etre une option
mopt = self.getmaster() mopt = self.getmaster()
mpath = mopt.impl_getpath(context) mpath = mopt.impl_getpath(context)
mopt.reset_cache(mopt, mopt.reset_cache(mopt,
mpath, mpath,
obj, values,
type_, settings,
resetted_opts) resetted_opts)
for slave in self.getslaves(): for slave in self.getslaves():
spath = slave.impl_getpath(context) spath = slave.impl_getpath(context)
slave.reset_cache(slave, slave.reset_cache(slave,
spath, spath,
obj, values,
type_, settings,
resetted_opts) resetted_opts)
def impl_validate_value(self, def impl_validate_value(self,