Reg: email sent to corresponding PIs
[myslice.git] / myslice / config.py
1 import os.path
2 from ConfigParser import RawConfigParser
3 from myslice.settings import ROOT
4
5 # as this code suggests, you have the option to override these defaults
6 # by writing a file myslice/myslice.ini
7 # that looks like this
8 #[manifold]
9 #url = http://manifold.pl.sophia.inria.fr:7080/
10 #admin_user = admin
11 #admin_password = admin
12
13 # use a singleton instead of staticmethods
14 from manifold.util.singleton    import Singleton
15
16 class Config(object):
17     __metaclass__ = Singleton
18
19     # the OpenLab-wide backend as managed by UPMC
20     # xxx production should probably use https of course
21     default_manifold_url = "https://test.myslice.info:7080/"
22     # the devel/unstable version runs on "https://dev.myslice.info:7080/"
23     # if you use a development backend running on this box, use "http://localhost:7080/"
24     # the INRIA setup is with "https://manifold.pl.sophia.inria.fr:7080/"
25
26     default_manifold_admin_user     = 'admin'
27     default_manifold_admin_password = 'demo'
28
29
30     def __init__ (self):
31         parser = RawConfigParser ()
32         parser.add_section('manifold')
33         parser.set ('manifold', 'url', Config.default_manifold_url)
34         parser.set ('manifold', 'admin_user', Config.default_manifold_admin_user)
35         parser.set ('manifold', 'admin_password', Config.default_manifold_admin_password)
36         parser.add_section('googlemap')
37         parser.set ('googlemap','api_key', None)
38         parser.read (os.path.join(ROOT,'myslice/myslice.ini'))
39         self.config_parser=parser
40
41     def manifold_url (self):
42         return self.config_parser.get('manifold','url')
43
44     def manifold_admin_user_password(self):
45         return (self.config_parser.get('manifold','admin_user'),
46                 self.config_parser.get('manifold','admin_password'))
47
48     def googlemap_api_key (self):
49         return self.config_parser.get('googlemap','api_key')
50
51     # exporting these details to js
52     def manifold_js_export (self):
53         return "var MANIFOLD_URL = '%s';\n"%self.manifold_url();