From a95f19d5f427f9b66db5156c9b2bdca29991ea12 Mon Sep 17 00:00:00 2001 From: gwen Date: Fri, 12 Jul 2013 16:20:34 +0200 Subject: [PATCH] default settings --- tiramisu/setting.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tiramisu/setting.py b/tiramisu/setting.py index a20f88a..d6537ef 100644 --- a/tiramisu/setting.py +++ b/tiramisu/setting.py @@ -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: