generic properties api
authorgwen <gremond@cadoles.com>
Fri, 14 Sep 2012 08:29:25 +0000 (10:29 +0200)
committergwen <gremond@cadoles.com>
Fri, 14 Sep 2012 08:29:25 +0000 (10:29 +0200)
tiramisu/config.py

index 90f767d..14240bf 100644 (file)
@@ -138,37 +138,22 @@ class Config(object):
     def _cfgimpl_has_properties(self):
         return bool(len(self._cfgimpl_properties))
 
-    def cfgimpl_hide(self):
-        if self._cfgimpl_parent != None:
-            raise MethodCallError("this method root_hide() shall not be"
-                                           "used with non-root Config() object") 
-        rootconfig = self._cfgimpl_get_toplevel()
-        if 'hidden' not in rootconfig._cfgimpl_properties:
-            rootconfig._cfgimpl_properties.append('hidden')
+    def _cfgimpl_has_property(self, propname):
+        return propname in self._cfgimpl_properties
 
-    def cfgimpl_show(self):
+    def cfgimpl_enable_property(self, propname):
         if self._cfgimpl_parent != None:
             raise MethodCallError("this method root_hide() shall not be"
                                            "used with non-root Config() object") 
-        rootconfig = self._cfgimpl_get_toplevel()
-        if 'hidden' in rootconfig._cfgimpl_properties:
-            rootconfig._cfgimpl_properties.remove('hidden')
-
-    def cfgimpl_disable(self):
-        if self._cfgimpl_parent != None:
-            raise MethodCallError("this method root_hide() shall not be"
-                                           "used with non-root Confit() object") 
-        rootconfig = self._cfgimpl_get_toplevel()
-        if 'disabled' not in rootconfig._cfgimpl_properties:
-            rootconfig._cfgimpl_properties.append('disabled')
-            
-    def cfgimpl_enable(self):
+        if propname not in in self._cfgimpl_properties:
+            self._cfgimpl_properties.append(propname)
+    
+    def cfgimpl_disable_property(self, propname):
         if self._cfgimpl_parent != None:
             raise MethodCallError("this method root_hide() shall not be"
-                                           "used with non-root Confit() object") 
-        rootconfig = self._cfgimpl_get_toplevel()
-        if 'disabled' in rootconfig._cfgimpl_properties:
-            rootconfig._cfgimpl_properties.remove('disabled')
+                                           "used with non-root Config() object") 
+        if self._cfgimpl_has_property(propname):
+            self.properties.remove(propname)
 
     def cfgimpl_non_mandatory(self):
         if self._cfgimpl_parent != None: