Merge branch 'jordan' of ssh://git.onelab.eu/git/myslice into jordan
authorJordan Augé <jordan.auge@lip6.fr>
Tue, 7 May 2013 08:39:09 +0000 (10:39 +0200)
committerJordan Augé <jordan.auge@lip6.fr>
Tue, 7 May 2013 08:39:09 +0000 (10:39 +0200)
manifold/manifoldapi.py
myslice/settings.py

index c0870ec..1826ba8 100644 (file)
@@ -76,11 +76,11 @@ class ManifoldAPI:
     def send_manifold_query (self, query):
         # We use a dictionary representation of the query for forwarding it to the API
         ret = self.forward(query.to_dict())
-        print "="*80
-        print "Result:"
-        print ret
-        print "="*80
-        print ret
+        if debug:
+            print "="*80
+            print "Result:"
+            print ret
+            print "="*80
         return ret
 
 #old#        (action,subject)= (query.action,query.subject)
index e5319f4..2dbb861 100644 (file)
@@ -5,11 +5,22 @@ import os.path
 DEBUG = True
 TEMPLATE_DEBUG = DEBUG
 
-# change these if you use a different convention
-
-DEVELOPER_ROOT=os.path.expanduser("~/repos/myslice-django")
-
-PRODUCTION_ROOT="/usr/share/myslice/USE_DEVELOPMENT"
+# compute ROOT from where this file is installed
+# should fit every need including developers
+# but you can redefine ROOT if that's not working for you
+try:
+    # get the directory where this file is
+    ROOT=os.path.dirname(__file__) or '.'
+    # move one step up
+    ROOT=os.path.realpath(ROOT+'/..')
+except:
+    ROOT=None
+    if DEBUG:
+        import traceback
+        traceback.print_exc()
+
+if not ROOT:
+    raise Exception,"Cannot find ROOT for myslice"
 
 ####################
 ADMINS = (
@@ -18,22 +29,6 @@ ADMINS = (
 
 MANAGERS = ADMINS
 
-####################
-# guess if we run on the 'prod' site (:) that for now uses /root/myslice and run manage.py
-# or on a working laptop, in which case we use ~/git/myslice-django
-import os, os.path
-ROOT=''
-def init_root ():
-    global ROOT
-    if os.path.exists(PRODUCTION_ROOT):
-        ROOT=PRODUCTION_ROOT
-    elif os.path.exists (DEVELOPER_ROOT):
-        ROOT=DEVELOPER_ROOT
-    else:
-        raise Exception,"Cannot find ROOT for myslice (neither %s nor %s)"%(PRODUCTION_ROOT,DEVELOPER_ROOT)
-
-init_root()
-
 DATABASES = {
     'default': {
         'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.