improve GroupConfig/MetaConfig
add set_value in GroupConfig
This commit is contained in:
@ -216,7 +216,6 @@ def populate_owners():
|
||||
setattr(owners, name, owners.Owner(name))
|
||||
setattr(owners, 'addowner', addowner)
|
||||
|
||||
|
||||
# ____________________________________________________________
|
||||
# populate groups and owners with default attributes
|
||||
groups = GroupModule()
|
||||
@ -334,8 +333,11 @@ class Settings(object):
|
||||
path = opt.impl_getpath(self._getcontext())
|
||||
return self._getitem(opt, path)
|
||||
|
||||
def _getitem(self, opt, path):
|
||||
return Property(self, self._getproperties(opt, path), opt, path)
|
||||
def _getitem(self, opt, path, self_properties=undefined):
|
||||
return Property(self,
|
||||
self._getproperties(opt, path,
|
||||
self_properties=self_properties),
|
||||
opt, path)
|
||||
|
||||
def __setitem__(self, opt, value): # pragma: optional cover
|
||||
raise ValueError(_('you should only append/remove properties'))
|
||||
@ -352,19 +354,22 @@ class Settings(object):
|
||||
self._p_.delproperties(_path)
|
||||
self._getcontext().cfgimpl_reset_cache()
|
||||
|
||||
def _getproperties(self, opt=None, path=None, _is_apply_req=True):
|
||||
def _getproperties(self, opt=None, path=None, _is_apply_req=True,
|
||||
self_properties=undefined):
|
||||
"""
|
||||
be careful, _is_apply_req doesn't copy properties
|
||||
"""
|
||||
if opt is None:
|
||||
props = copy(self._p_.getproperties(path, default_properties))
|
||||
else:
|
||||
if self_properties is undefined:
|
||||
self_properties = self._getproperties()
|
||||
if path is None: # pragma: optional cover
|
||||
raise ValueError(_('if opt is not None, path should not be'
|
||||
' None in _getproperties'))
|
||||
ntime = None
|
||||
if 'cache' in self and self._p_.hascache(path):
|
||||
if 'expire' in self:
|
||||
if 'cache' in self_properties and self._p_.hascache(path):
|
||||
if 'expire' in self_properties:
|
||||
ntime = int(time())
|
||||
is_cached, props = self._p_.getcache(path, ntime)
|
||||
if is_cached:
|
||||
@ -373,8 +378,8 @@ class Settings(object):
|
||||
if _is_apply_req:
|
||||
props = copy(props)
|
||||
props |= self.apply_requires(opt, path)
|
||||
if 'cache' in self:
|
||||
if 'expire' in self:
|
||||
if 'cache' in self_properties:
|
||||
if 'expire' in self_properties:
|
||||
if ntime is None:
|
||||
ntime = int(time())
|
||||
ntime = ntime + expires_time
|
||||
@ -412,7 +417,8 @@ class Settings(object):
|
||||
#____________________________________________________________
|
||||
def validate_properties(self, opt_or_descr, is_descr, is_write, path,
|
||||
value=None, force_permissive=False,
|
||||
force_properties=None, force_permissives=None):
|
||||
force_properties=None, force_permissives=None,
|
||||
self_properties=undefined):
|
||||
"""
|
||||
validation upon the properties related to `opt_or_descr`
|
||||
|
||||
@ -432,8 +438,10 @@ class Settings(object):
|
||||
(typically with the `frozen` property)
|
||||
"""
|
||||
# opt properties
|
||||
properties = self._getproperties(opt_or_descr, path)
|
||||
self_properties = self._getproperties()
|
||||
if self_properties is undefined:
|
||||
self_properties = self._getproperties()
|
||||
properties = self._getproperties(opt_or_descr, path,
|
||||
self_properties=self_properties)
|
||||
# remove opt permissive
|
||||
# permissive affect option's permission with or without permissive
|
||||
# global property
|
||||
|
Reference in New Issue
Block a user