9cf2407253f7b4881faff2be64c5fb5ffdbb78c3
[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 write myslice/myslice.ini
6 # that looks like this
7 #[manifold]
8 #url = http://manifold.pl.sophia.inria.fr:7080/
9
10 class Config:
11
12     # the OpenLab-wide backend as managed by UPMC
13     # xxx production should probably use https of course
14     default_manifold_url = "http://test.myslice.info:7080/"
15     # the devel/unstable version runs on "http://dev.myslice.info:7080/"
16     # if you use a development backend running on this box, use "http://localhost:7080/"
17     # the INRIA setup is with "http://manifold.pl.sophia.inria.fr:7080/"
18
19     _config_parser = None
20
21     # having grown tired of screwing up with git stashes 
22     # taking away my local config, we now more properly use
23     # an external config file to override teh default
24     @staticmethod
25     def manifold_url ():
26         if Config._config_parser: 
27             return Config._config_parser.get('manifold','url')
28         config = RawConfigParser ()
29         config.add_section('manifold')
30         config.set ('manifold', 'url', Config.default_manifold_url)
31         config.read (os.path.join(ROOT,'myslice/myslice.ini'))
32         Config._config_parser=config
33         return Config.manifold_url()
34
35     # exporting these details to js
36     @staticmethod
37     def manifold_js_export ():
38         return "var MANIFOLD_URL = '%s';\n"%Config.manifold_url();