manifold url can be configured in myslice.ini - instead of in the git repo - so we...
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Tue, 1 Oct 2013 11:17:45 +0000 (13:17 +0200)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Tue, 1 Oct 2013 12:22:13 +0000 (14:22 +0200)
manifold/manifoldapi.py
myslice/config.py
portal/homeview.py
portal/templates/home-view.html

index 47cf4c9..3fa5f97 100644 (file)
@@ -27,7 +27,7 @@ class ManifoldAPI:
         self.trace = []
         self.calls = {}
         self.multicall = False
-        self.url = config.manifold_url
+        self.url = config.manifold_url()
         self.server = xmlrpclib.Server(self.url, verbose=False, allow_none=True)
 
     def __repr__ (self): return "ManifoldAPI[%s]"%self.url
index c0e171b..9cf2407 100644 (file)
@@ -1,18 +1,38 @@
+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
+# that looks like this
+#[manifold]
+#url = http://manifold.pl.sophia.inria.fr:7080/
+
 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/"
 
-# 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
+    @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()
 
-# 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
     # 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();
index b5e47fe..b9d039a 100644 (file)
@@ -15,7 +15,7 @@ class HomeView (View):
     # expose this so we can mention the backend URL on the welcome page
     def default_env (self):
         return { 
-                 'manifold_url':Config.manifold_url,
+                 'MANIFOLD_URL':Config.manifold_url(),
                  }
 
     def post (self,request):
index 5072e52..123bc28 100644 (file)
@@ -25,7 +25,7 @@ European and national projects, OneLab offers access to a range of  tools and
 testbeds including PlanetLab Europe, the NITOS wireless testbed, and other
 federated testbeds.
 </p>
-<p>This UI server is connected to the manifold backend running at <code>{{ manifold_url }}</code>.</p>
+<p>This UI server is connected to the manifold backend running at <code>{{ MANIFOLD_URL }}</code>.</p>
 </div>
 
 {% endblock unfold2_main %}