Merge branch 'fibre' of ssh://git.onelab.eu/git/myslice into fibre
[unfold.git] / myslice / configengine.py
index 8c98b4c..1a46e6d 100644 (file)
@@ -33,6 +33,7 @@ class ConfigEngine(object):
 
     default_manifold_admin_user     = 'admin'
     default_manifold_admin_password = 'demo'
+    default_myslice_theme           = 'fibre'
 
 
     def __init__ (self):
@@ -41,11 +42,21 @@ class ConfigEngine(object):
         parser.set ('manifold', 'url', ConfigEngine.default_manifold_url)
         parser.set ('manifold', 'admin_user', ConfigEngine.default_manifold_admin_user)
         parser.set ('manifold', 'admin_password', ConfigEngine.default_manifold_admin_password)
+
+        parser.add_section('myslice')
+        parser.set ('myslice', 'theme', ConfigEngine.default_myslice_theme)
+
         parser.add_section('googlemap')
         parser.set ('googlemap','api_key', None)
+        print os.path.join(ROOT,'myslice/myslice.ini')
         parser.read (os.path.join(ROOT,'myslice/myslice.ini'))
+        print parser
         self.config_parser=parser
 
+    def __getattr__(self, section):
+        if self.config_parser.has_section(section):
+            return ConfigSection(self.config_parser, section)
+        
     def manifold_url (self):
         return self.config_parser.get('manifold','url')
 
@@ -59,3 +70,13 @@ class ConfigEngine(object):
     # exporting these details to js
     def manifold_js_export (self):
         return "var MANIFOLD_URL = '%s';\n"%self.manifold_url();
+
+class ConfigSection(object) :
+    
+    def __init__(self, parser, section):
+        self._parser = parser
+        self._section = section
+    
+    def __getattr__(self, key):
+        if self._parser.has_option(self._section, key):
+            return self._parser.get(self._section, key)