works on performante
authorGarette Emmanuel <egarette@cadoles.com>
Tue, 26 Mar 2013 09:29:49 +0000 (10:29 +0100)
committerGarette Emmanuel <egarette@cadoles.com>
Tue, 26 Mar 2013 09:29:49 +0000 (10:29 +0100)
tiramisu/config.py
tiramisu/option.py
tiramisu/setting.py

index c47932a..4849590 100644 (file)
@@ -33,9 +33,12 @@ from tiramisu.value import Values
 # ____________________________________________________________
 class Config(object):
     "main configuration management entry"
+#    __slots__ = ('__dict__', '_cfgimpl_toplevel', '_cfgimpl_descr', '_cfgimpl_subconfigs',
+#            '_cfgimpl_parent', '_cfgimpl_all_paths', '_cfgimpl_warnings',
+#            '_cfgimpl_toplevel', '_cfgimpl_slots', '_cfgimpl_build_all_paths')
     _cfgimpl_toplevel = None
 
-    def __init__(self, descr, parent=None, context=None):
+    def __init__(self, descr, parent=None, context=None, valid_opt_names=True):
         """ Configuration option management master class
 
         :param descr: describes the configuration schema
@@ -57,21 +60,23 @@ class Config(object):
             self._cfgimpl_context = context
         if parent is None:
             self._cfgimpl_settings = Setting()
+            self._cfgimpl_settings.valid_opt_names = valid_opt_names
             self._cfgimpl_values = Values(self._cfgimpl_context)
             self._cfgimpl_all_paths = {}
         else:
             if context is None:
                 raise ConfigError("cannot find a value for this config")
-            self._cfgimpl_settings = None
-            self._cfgimpl_values = None
-            self._cfgimpl_all_paths = None
+            valid_opt_names = context._cfgimpl_settings.valid_opt_names
         "warnings are a great idea, let's make up a better use of it"
         self._cfgimpl_warnings = []
         self._cfgimpl_toplevel = self._cfgimpl_get_toplevel()
-        # some api members shall not be used as option's names !
-        methods = getmembers(self, ismethod)
-        self._cfgimpl_slots = [key for key, value in methods
-                              if not key.startswith("_")]
+        if valid_opt_names:
+            # some api members shall not be used as option's names !
+            #methods = getmembers(self, ismethod)
+            self._cfgimpl_slots = []  #[key for key, value in methods
+                                  #if not key.startswith("_")]
+        else:
+            self._cfgimpl_slots = []
         self._cfgimpl_build()
         if parent is None:
             self._cfgimpl_build_all_paths()
index cdd180c..f538c0a 100644 (file)
@@ -486,7 +486,7 @@ class OptionDescription(BaseType, BaseInformation):
                 option.build_cache(paths, currpath=currpath)
                 currpath.pop()
             else:
-                paths[option] = '.'.join(currpath + [attr])
+                paths[option] = str('.'.join(currpath + [attr]))
 
     # ____________________________________________________________
     def set_group_type(self, group_type):
index 6bdcb13..7477fd9 100644 (file)
@@ -131,6 +131,9 @@ class Setting():
     owner = owners.user
     # in order to freeze everything, not **only** the frozen options
     everything_frozen = False
+    # enables at build time to raise an exception if the option's name
+    # has the name of a config's method
+    valid_opt_names = True
     #____________________________________________________________
     # properties methods
     def has_properties(self):