add option name's validation and rename Option method with objimpl_
[tiramisu.git] / tiramisu / setting.py
index c3372ce..de698e9 100644 (file)
@@ -26,6 +26,10 @@ from tiramisu.i18n import _
 
 
 expires_time = 5
+ro_remove = ('permissive', 'hidden')
+ro_append = ('frozen', 'disabled', 'validator', 'everything_frozen', 'mandatory')
+rw_remove = ('permissive', 'everything_frozen', 'mandatory')
+rw_append = ('frozen', 'disabled', 'validator', 'hidden')
 
 
 class _const:
@@ -303,25 +307,19 @@ class Setting(object):
         return self._owner
 
     #____________________________________________________________
+    def _read(self, remove, append):
+        for prop in remove:
+            self.remove(prop)
+        for prop in append:
+            self.append(prop)
+
     def read_only(self):
         "convenience method to freeze, hidde and disable"
-        self.append('everything_frozen')
-        self.append('frozen')  # can be usefull...
-        self.remove('hidden')
-        self.append('disabled')
-        self.append('mandatory')
-        self.append('validator')
-        self.remove('permissive')
+        self._read(ro_remove, ro_append)
 
     def read_write(self):
         "convenience method to freeze, hidde and disable"
-        self.remove('everything_frozen')
-        self.append('frozen')  # can be usefull...
-        self.append('hidden')
-        self.append('disabled')
-        self.remove('mandatory')
-        self.append('validator')
-        self.remove('permissive')
+        self._read(rw_remove, rw_append)
 
     def _set_cache(self, opt, props):
         if 'expire' in self:
@@ -355,7 +353,7 @@ def apply_requires(opt, config):
         settings = config.cfgimpl_get_settings()
         setting = Property(settings, settings._get_properties(opt, False), opt)
         trigger_actions = build_actions(opt._requires)
-        optpath = config.cfgimpl_get_context().cfgimpl_get_description().get_path_by_opt(opt)
+        optpath = config.cfgimpl_get_context().cfgimpl_get_description().objimpl_get_path_by_opt(opt)
         for requires in trigger_actions.values():
             matches = False
             for require in requires: