impl_get_information and impl_set_information are, now, persistent in storage
[tiramisu.git] / tiramisu / config.py
index ae68e98..8537c0d 100644 (file)
 # ____________________________________________________________
 import weakref
 from tiramisu.error import PropertiesOptionError, ConfigError
 # ____________________________________________________________
 import weakref
 from tiramisu.error import PropertiesOptionError, ConfigError
-from tiramisu.option import OptionDescription, Option, SymLinkOption, \
-    BaseInformation
+from tiramisu.option import OptionDescription, Option, SymLinkOption
 from tiramisu.setting import groups, Settings, default_encoding, get_storage
 from tiramisu.value import Values
 from tiramisu.i18n import _
 
 
 from tiramisu.setting import groups, Settings, default_encoding, get_storage
 from tiramisu.value import Values
 from tiramisu.i18n import _
 
 
-class SubConfig(BaseInformation):
+class SubConfig(object):
     "sub configuration management entry"
     __slots__ = ('_impl_context', '_impl_descr', '_impl_path')
 
     "sub configuration management entry"
     __slots__ = ('_impl_context', '_impl_descr', '_impl_path')
 
@@ -252,10 +251,10 @@ class SubConfig(BaseInformation):
             :returns: list of matching Option objects
         """
         return self._cfgimpl_get_context()._find(bytype, byname, byvalue,
             :returns: list of matching Option objects
         """
         return self._cfgimpl_get_context()._find(bytype, byname, byvalue,
-                                                first=False,
-                                                type_=type_,
-                                                _subpath=self.cfgimpl_get_path()
-                                                )
+                                                 first=False,
+                                                 type_=type_,
+                                                 _subpath=self.cfgimpl_get_path()
+                                                 )
 
     def find_first(self, bytype=None, byname=None, byvalue=None,
                    type_='option', display_error=True):
 
     def find_first(self, bytype=None, byname=None, byvalue=None,
                    type_='option', display_error=True):
@@ -501,6 +500,22 @@ class CommonConfig(SubConfig):
     def cfgimpl_get_meta(self):
         return self._impl_meta
 
     def cfgimpl_get_meta(self):
         return self._impl_meta
 
+    # information
+    def impl_set_information(self, key, value):
+        """updates the information's attribute
+
+        :param key: information's key (ex: "help", "doc"
+        :param value: information's value (ex: "the help string")
+        """
+        self._impl_values.set_information(key, value)
+
+    def impl_get_information(self, key, default=None):
+        """retrieves one information's item
+
+        :param key: the item string (ex: "help")
+        """
+        return self._impl_values.get_information(key, default)
+
 
 # ____________________________________________________________
 class Config(CommonConfig):
 
 # ____________________________________________________________
 class Config(CommonConfig):
@@ -526,7 +541,6 @@ class Config(CommonConfig):
         super(Config, self).__init__(descr, weakref.ref(self))
         self._impl_build_all_paths()
         self._impl_meta = None
         super(Config, self).__init__(descr, weakref.ref(self))
         self._impl_build_all_paths()
         self._impl_meta = None
-        self._impl_informations = {}
 
     def cfgimpl_reset_cache(self,
                             only_expired=False,
 
     def cfgimpl_reset_cache(self,
                             only_expired=False,
@@ -565,7 +579,6 @@ class Config(CommonConfig):
 #        self._impl_settings = Settings(self, storage)
 #        self._impl_values = Values(self, storage)
 #        self._impl_meta = None
 #        self._impl_settings = Settings(self, storage)
 #        self._impl_values = Values(self, storage)
 #        self._impl_meta = None
-#        self._impl_informations = {}
 
 #    def cfgimpl_get_children(self):
 #        return self._impl_children
 
 #    def cfgimpl_get_children(self):
 #        return self._impl_children