2 from ConfigParser import RawConfigParser
3 from myslice.settings import ROOT
8 # This file does not contain any user-modifiable data
10 # te defaults here are, well, only default values,
11 # and, you have the option to override them
12 # by writing a file myslice/myslice.ini
13 # that looks like this
15 #url = http://manifold.pl.sophia.inria.fr:7080/
17 #admin_password = admin
19 #api_key=theapikeyasprovidedbygoogle
21 # use a singleton instead of staticmethods
22 from manifold.util.singleton import Singleton
24 class ConfigEngine(object):
25 __metaclass__ = Singleton
27 # the OpenLab-wide backend as managed by UPMC
28 # xxx production should probably use https of course
29 default_manifold_url = "https://test.myslice.info:7080/"
30 # the devel/unstable version runs on "https://dev.myslice.info:7080/"
31 # if you use a development backend running on this box, use "http://localhost:7080/"
32 # the INRIA setup is with "https://manifold.pl.sophia.inria.fr:7080/"
34 default_manifold_admin_user = 'admin'
35 default_manifold_admin_password = 'demo'
39 parser = RawConfigParser ()
40 parser.add_section('manifold')
41 parser.set ('manifold', 'url', ConfigEngine.default_manifold_url)
42 parser.set ('manifold', 'admin_user', ConfigEngine.default_manifold_admin_user)
43 parser.set ('manifold', 'admin_password', ConfigEngine.default_manifold_admin_password)
44 parser.add_section('googlemap')
45 parser.set ('googlemap','api_key', None)
46 parser.read (os.path.join(ROOT,'myslice/myslice.ini'))
47 self.config_parser=parser
49 def __getattr__(self, section):
50 if self.config_parser.has_section(section):
51 return ConfigSection(self.config_parser, section)
53 def manifold_url (self):
54 return self.config_parser.get('manifold','url')
56 def manifold_admin_user_password(self):
57 return (self.config_parser.get('manifold','admin_user'),
58 self.config_parser.get('manifold','admin_password'))
60 def googlemap_api_key (self):
61 return self.config_parser.get('googlemap','api_key')
63 # exporting these details to js
64 def manifold_js_export (self):
65 return "var MANIFOLD_URL = '%s';\n"%self.manifold_url();
67 class ConfigSection(object) :
69 def __init__(self, parser, section):
71 self._section = section
73 def __getattr__(self, key):
74 if self._parser.has_option(self._section, key):
75 return self._parser.get(self._section, key)