X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=myslice%2Fconfig.py;h=31dc7e318de75a88b6c61576bb78f09592205c6f;hb=be1dd95ef614c4ae1793c17dcc7edb96c2a69e1a;hp=7e0fadd0b51c62331a645edd4fe3b01ec84c5e64;hpb=738825ec1a1884d06ff43343a6208a17d0411c41;p=unfold.git diff --git a/myslice/config.py b/myslice/config.py index 7e0fadd0..31dc7e31 100644 --- a/myslice/config.py +++ b/myslice/config.py @@ -1,20 +1,59 @@ +import os.path +from ConfigParser import RawConfigParser +from myslice.settings import ROOT + +# myslice/myslice.ini +# as this code suggests, you have the option to write myslice/myslice.ini +# that looks like this +#[manifold] +#url = http://manifold.pl.sophia.inria.fr:7080/ +#admin_user = admin +#admin_password = admin + class Config: -# this version of unfold expects a backend that runs a new API + # the OpenLab-wide backend as managed by UPMC + # xxx production should probably use https of course + default_manifold_url = "http://test.myslice.info:7080/" + # the devel/unstable version runs on "http://dev.myslice.info:7080/" + # if you use a development backend running on this box, use "http://localhost:7080/" + # the INRIA setup is with "http://manifold.pl.sophia.inria.fr:7080/" + + default_manifold_admin_user = 'admin' + default_manifold_admin_password = None -# production should probably use https of course + _config_parser = None + # having grown tired of screwing up with git stashes + # taking away my local config, we now more properly use + # an external config file to override teh default + # XXX we might use support from manifold util classes --jordan + @staticmethod + def manifold_url (): + if Config._config_parser: + return Config._config_parser.get('manifold','url') + config = RawConfigParser () + config.add_section('manifold') + config.set ('manifold', 'url', Config.default_manifold_url) + config.read (os.path.join(ROOT,'myslice/myslice.ini')) + Config._config_parser=config + return Config.manifold_url() + + @staticmethod + def manifold_admin_user_password(): + if Config._config_parser: + admin_user = Config._config_parser.get('manifold','admin_user') + admin_password = Config._config_parser.get('manifold','admin_password') + return (admin_user, admin_password) + config = RawConfigParser () + config.add_section('manifold') + config.set ('manifold', 'admin_user', Config.default_manifold_admin_user) + config.set ('manifold', 'admin_password', Config.default_manifold_admin_password) + config.read (os.path.join(ROOT,'myslice/myslice.ini')) + Config._config_parser=config + return Config.manifold_admin_user_password() -# 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 version -# manifold_url = "http://localhost:7080/" #stable version - # exporting these details to js @staticmethod def manifold_js_export (): - return "var MANIFOLD_URL = '%s';\n"%Config.manifold_url; + return "var MANIFOLD_URL = '%s';\n"%Config.manifold_url();