X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=myslice%2Fconfig.py;h=04f4aaf80ca5fba87318a30675611a910df29e24;hb=5f03119b3bc1f16e68dd805c4b5773ba1ee7148e;hp=8d2d28b36d041060f1cbd20f277d53793acdc3d2;hpb=6656b13932a99246b7e75af4ba2f0a137af1bfe1;p=myslice.git diff --git a/myslice/config.py b/myslice/config.py index 8d2d28b3..04f4aaf8 100644 --- a/myslice/config.py +++ b/myslice/config.py @@ -1,16 +1,48 @@ -class Config: +import os.path +from ConfigParser import RawConfigParser +from myslice.settings import ROOT - # production should use https of course +# 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 -# this version of unfold expects a backend that runs a new API -# xxx -# -- although currently (april 2013) there are missing features -# e.g. GetSession and GetPersons are still there -- they should go away -# also the code for retrieving metadata does not work as-is -# manifold_url = "http://localhost:7080/" - manifold_url = "http://dev.myslice.info:7080/" +# 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.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')) # 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();