X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=myslice%2Fconfig.py;h=61c22817e3a86672dbd514abfe158ae02f1fbade;hb=4920497313e03cc832c29aaae13e45ca060ccc94;hp=9cf2407253f7b4881faff2be64c5fb5ffdbb78c3;hpb=10af098ebfcc500aef11ce9154028b8e20a0b046;p=myslice.git diff --git a/myslice/config.py b/myslice/config.py index 9cf24072..61c22817 100644 --- a/myslice/config.py +++ b/myslice/config.py @@ -2,12 +2,19 @@ import os.path from ConfigParser import RawConfigParser from myslice.settings import ROOT -# as this code suggests, you have the option to write myslice/myslice.ini +# 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 -class Config: +# 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 @@ -16,23 +23,26 @@ class Config: # 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/" - _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 - @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() + default_manifold_admin_user = 'admin' + default_manifold_admin_password = 'admin' + + + 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();