Demo OpenLab Debug off in manifold/static/js/manifold.js
[unfold.git] / myslice / config.py
1 import os.path
2 from ConfigParser import RawConfigParser
3 from myslice.settings import ROOT
4
5 # myslice/myslice.ini
6 # as this code suggests, you have the option to write 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 class Config:
14
15     # the OpenLab-wide backend as managed by UPMC
16     # xxx production should probably use https of course
17     default_manifold_url = "http://test.myslice.info:7080/"
18     # the devel/unstable version runs on "http://dev.myslice.info:7080/"
19     # if you use a development backend running on this box, use "http://localhost:7080/"
20     # the INRIA setup is with "http://manifold.pl.sophia.inria.fr:7080/"
21
22     default_manifold_admin_user     = 'admin'
23     default_manifold_admin_password = None
24
25     _config_parser = None
26
27     # having grown tired of screwing up with git stashes 
28     # taking away my local config, we now more properly use
29     # an external config file to override teh default
30     # XXX we might use support from manifold util classes --jordan
31     @staticmethod
32     def manifold_url ():
33         if Config._config_parser: 
34             return Config._config_parser.get('manifold','url')
35         config = RawConfigParser ()
36         config.add_section('manifold')
37         config.set ('manifold', 'url', Config.default_manifold_url)
38         config.read (os.path.join(ROOT,'myslice/myslice.ini'))
39         Config._config_parser=config
40         return Config.manifold_url()
41
42     @staticmethod
43     def manifold_admin_user_password():
44         if Config._config_parser: 
45             admin_user = Config._config_parser.get('manifold','admin_user')
46             admin_password = Config._config_parser.get('manifold','admin_password')
47             return (admin_user, admin_password)
48         config = RawConfigParser ()
49         config.add_section('manifold')
50         config.set ('manifold', 'admin_user', Config.default_manifold_admin_user)
51         config.set ('manifold', 'admin_password', Config.default_manifold_admin_password)
52         config.read (os.path.join(ROOT,'myslice/myslice.ini'))
53         Config._config_parser=config
54         return Config.manifold_admin_user_password()
55
56     # exporting these details to js
57     @staticmethod
58     def manifold_js_export ():
59         return "var MANIFOLD_URL = '%s';\n"%Config.manifold_url();