X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=myslice%2Fconfig.py;h=908b6512ea8caf148d1d7c779a553d2389e7141d;hb=2870580fcaad4c3f1a2b9fa75499dcd4f7297449;hp=f6285b25571b7271d29ab1f9754b34ea257f6bf8;hpb=1aea42c3668602aacfe22bc762ee939672129f53;p=unfold.git diff --git a/myslice/config.py b/myslice/config.py index f6285b25..908b6512 100644 --- a/myslice/config.py +++ b/myslice/config.py @@ -1,18 +1,53 @@ -class Config: +import os.path +from ConfigParser import RawConfigParser +from myslice.settings import ROOT -# this version of unfold expects a backend that runs a new API +# as this code suggests, you have the option to override these defaults +# by writing a file myslice/myslice.ini +# that looks like this +#[manifold] +#url = http://manifold.pl.sophia.inria.fr:7080/ +#admin_user = admin +#admin_password = admin -# production should probably use https of course +# use a singleton instead of staticmethods +from manifold.util.singleton import Singleton +class Config(object): + __metaclass__ = Singleton + + # the OpenLab-wide backend as managed by UPMC + # xxx production should probably use https of course + default_manifold_url = "https://test.myslice.info:7080/" + # the devel/unstable version runs on "https://dev.myslice.info:7080/" + # if you use a development backend running on this box, use "http://localhost:7080/" + # the INRIA setup is with "https://manifold.pl.sophia.inria.fr:7080/" + + default_manifold_admin_user = 'admin' + default_manifold_admin_password = 'demo' + + + def __init__ (self): + parser = RawConfigParser () + parser.add_section('manifold') + parser.set ('manifold', 'url', Config.default_manifold_url) + parser.set ('manifold', 'admin_user', Config.default_manifold_admin_user) + parser.set ('manifold', 'admin_password', Config.default_manifold_admin_password) + parser.add_section('googlemap') + parser.set ('googlemap','api_key', None) + parser.read (os.path.join(ROOT,'myslice/myslice.ini')) + self.config_parser=parser + + def manifold_url (self): + return self.config_parser.get('manifold','url') + + def manifold_admin_user_password(self): + return (self.config_parser.get('manifold','admin_user'), + self.config_parser.get('manifold','admin_password')) + + def googlemap_api_key (self): + return self.config_parser.get('googlemap','api_key') -# if you use a development backend running on this box -# manifold_url = "http://localhost:7080/" -# the INRIA setup -# manifold_url = "http://manifold.pl.sophia.inria.fr:7080/" -# the OpenLab-wide backend as managed by UPMC -# manifold_url = "http://dev.myslice.info:7080/" # development version - manifold_url = "http://test.myslice.info:7080/" #stable manifol # exporting these details to js - @staticmethod - def manifold_js_export (): - return "var MANIFOLD_URL = '%s';\n"%Config.manifold_url; + def manifold_js_export (self): + return "var MANIFOLD_URL = '%s';\n"%self.manifold_url();