default settings

This commit is contained in:
gwen 2013-07-12 16:20:34 +02:00
parent c53d574ac2
commit a95f19d5f4

View File

@ -32,7 +32,7 @@ ro_remove = ('permissive', 'hidden')
ro_append = ('frozen', 'disabled', 'validator', 'everything_frozen', 'mandatory')
rw_remove = ('permissive', 'everything_frozen', 'mandatory')
rw_append = ('frozen', 'disabled', 'validator', 'hidden')
default_properties = set(('expire', 'validator'))
class _const:
"""convenient class that emulates a module
@ -182,7 +182,7 @@ class Setting(object):
def __init__(self, context):
# properties attribute: the name of a property enables this property
# key is None for global properties
self._properties = {None: set(('expire', 'validator'))}
self._properties = {}
# permissive properties
self._permissives = {}
# generic owner
@ -204,9 +204,16 @@ class Setting(object):
def __setitem__(self, opt, value):
raise ValueError('you must only append/remove properties')
def reset(self):
try:
del(self._properties[None])
except KeyError:
pass
self.context.cfgimpl_reset_cache()
def _get_properties(self, opt=None, is_apply_req=True):
if opt is None:
props = self._properties.get(opt, set())
props = self._properties.get(opt, copy(default_properties))
else:
exp = None
if opt in self._cache: