Merge branch 'master' into orm
[tiramisu.git] / tiramisu / config.py
index a923d47..ea7a6b3 100644 (file)
@@ -73,21 +73,24 @@ class SubConfig(object):
                                  force_properties=force_properties)
         return self, path[-1]
 
-    def __hash__(self):
-        return hash(self.cfgimpl_get_description().impl_getkey(self))
-
-    def __eq__(self, other):
-        "Config's comparison"
-        if not isinstance(other, Config):
-            return False
-        return self.cfgimpl_get_description().impl_getkey(self) == \
-            other.cfgimpl_get_description().impl_getkey(other)
-
-    def __ne__(self, other):
-        "Config's comparison"
-        if not isinstance(other, Config):
-            return True
-        return not self == other
+    #def __hash__(self):
+    #FIXME
+    #    return hash(self.cfgimpl_get_description().impl_getkey(self))
+
+    #def __eq__(self, other):
+    #FIXME
+    #    "Config's comparison"
+    #    if not isinstance(other, Config):
+    #        return False
+    #    return self.cfgimpl_get_description().impl_getkey(self) == \
+    #        other.cfgimpl_get_description().impl_getkey(other)
+
+    #def __ne__(self, other):
+    #FIXME
+    #    "Config's comparison"
+    #    if not isinstance(other, Config):
+    #        return True
+    #    return not self == other
 
     # ______________________________________________________________________
     def __iter__(self):
@@ -96,7 +99,7 @@ class SubConfig(object):
         for child in self.cfgimpl_get_description().impl_getchildren():
             if not isinstance(child, OptionDescription):
                 try:
-                    yield child._name, getattr(self, child._name)
+                    yield child.impl_getname(), getattr(self, child.impl_getname())
                 except GeneratorExit:
                     raise StopIteration
                 except PropertiesOptionError:
@@ -107,7 +110,7 @@ class SubConfig(object):
         iteration on Options and OptionDescriptions."""
         for child in self.cfgimpl_get_description().impl_getchildren():
             try:
-                yield child._name, getattr(self, child._name)
+                yield child.impl_getname(), getattr(self, child.impl_getname())
             except GeneratorExit:
                 raise StopIteration
             except PropertiesOptionError:
@@ -131,7 +134,7 @@ class SubConfig(object):
                     if group_type is None or (group_type is not None and
                                               child.impl_get_group_type()
                                               == group_type):
-                        yield child._name, getattr(self, child._name)
+                        yield child.impl_getname(), getattr(self, child.impl_getname())
                 except GeneratorExit:
                     raise StopIteration
                 except PropertiesOptionError:
@@ -256,7 +259,7 @@ class SubConfig(object):
             finds a list of options recursively in the config
 
             :param bytype: Option class (BoolOption, StrOption, ...)
-            :param byname: filter by Option._name
+            :param byname: filter by Option.impl_getname()
             :param byvalue: filter by the option's value
             :returns: list of matching Option objects
         """
@@ -272,7 +275,7 @@ class SubConfig(object):
             finds an option recursively in the config
 
             :param bytype: Option class (BoolOption, StrOption, ...)
-            :param byname: filter by Option._name
+            :param byname: filter by Option.impl_getname()
             :param byvalue: filter by the option's value
             :returns: list of matching Option objects
         """
@@ -322,12 +325,11 @@ class SubConfig(object):
             raise ValueError(_('unknown type_ type {0}'
                                'for _find').format(type_))
         find_results = []
-        opts, paths = self.cfgimpl_get_description()._cache_paths
-        for index in range(0, len(paths)):
-            option = opts[index]
+        paths = self.cfgimpl_get_description()._cache_paths[1]
+        for path in paths:
+            option = self.cfgimpl_get_description().impl_get_opt_by_path(path)
             if isinstance(option, OptionDescription):
                 continue
-            path = paths[index]
             if _subpath is not None and not path.startswith(_subpath + '.'):
                 continue
             if not _filter_by_name():
@@ -437,7 +439,7 @@ class SubConfig(object):
         #withoption can be set to None below !
         if withoption is None:
             for opt in self.cfgimpl_get_description().impl_getchildren():
-                path = opt._name
+                path = opt.impl_getname()
                 self._make_sub_dict(opt, path, pathsvalues, _currpath, flatten)
         if _currpath == []:
             options = dict(pathsvalues)
@@ -454,11 +456,11 @@ class SubConfig(object):
                 pass  # this just a hidden or disabled option
         else:
             try:
-                value = self._getattr(opt._name)
+                value = self._getattr(opt.impl_getname())
                 if flatten:
-                    name = opt._name
+                    name = opt.impl_getname()
                 else:
-                    name = '.'.join(_currpath + [opt._name])
+                    name = '.'.join(_currpath + [opt.impl_getname()])
                 pathsvalues.append((name, value))
             except PropertiesOptionError:
                 pass  # this just a hidden or disabled option