Replace get_path with dict indexing
[pithos-web-client] / snf-pithos-webclient / pithos_webclient / settings.py
index 99a6375..7e75e8d 100644 (file)
 # interpreted as representing official policies, either expressed
 # or implied, of GRNET S.A.
 
+import pithos.api.settings as pithos_settings
+
+from pithos.api.settings import LazyAstakosUrl
 from django.conf import settings
 from synnefo.lib import join_urls, parse_base_url
-from synnefo.util.keypath import get_path
 from pithos.api.services import pithos_services as vanilla_pithos_services
-from astakosclient import astakos_services as vanilla_astakos_services
 from synnefo.lib.services import get_public_endpoint, fill_endpoints
 
 from copy import deepcopy
 
-# Process Pithos settings. This code is shared between snf-pithos-app and
-# snf-pithos-webclient since they share the PITHOS_ settings prefix for most
-# of their settings.
+# --------------------------------------------------------------------
+# Process Pithos settings
+
+# This code is shared between snf-pithos-app and snf-pithos-webclient since
+# they share the PITHOS_ settings prefix for most of their settings.
 BASE_URL = getattr(settings, 'PITHOS_BASE_URL',
                    "https://object-store.example.synnefo.org/pithos/")
 
 BASE_HOST, BASE_PATH = parse_base_url(BASE_URL)
 
-# Process Astakos settings
-ASTAKOS_BASE_URL = getattr(settings, 'ASTAKOS_BASE_URL',
-                           'https://accounts.example.synnefo.org/astakos/')
-ASTAKOS_BASE_HOST, ASTAKOS_BASE_PATH = parse_base_url(ASTAKOS_BASE_URL)
-
 pithos_services = deepcopy(vanilla_pithos_services)
 fill_endpoints(pithos_services, BASE_URL)
-PITHOS_PREFIX = get_path(pithos_services, 'pithos_object-store.prefix')
-PUBLIC_PREFIX = get_path(pithos_services, 'pithos_public.prefix')
-UI_PREFIX = get_path(pithos_services, 'pithos_ui.prefix')
-
-astakos_services = deepcopy(vanilla_astakos_services)
-fill_endpoints(astakos_services, ASTAKOS_BASE_URL)
-CUSTOMIZE_ASTAKOS_SERVICES = \
-        getattr(settings, 'PITHOS_CUSTOMIZE_ASTAKOS_SERVICES', ())
-for path, value in CUSTOMIZE_ASTAKOS_SERVICES:
-    set_path(astakos_services, path, value, createpath=True)
-
-ASTAKOS_ACCOUNTS_PREFIX = get_path(astakos_services, 'astakos_account.prefix')
-ASTAKOS_VIEWS_PREFIX = get_path(astakos_services, 'astakos_ui.prefix')
-ASTAKOS_KEYSTONE_PREFIX = get_path(astakos_services, 'astakos_keystone.prefix')
-
-BASE_ASTAKOS_PROXY_PATH = getattr(settings, 'PITHOS_BASE_ASTAKOS_PROXY_PATH',
-                                  ASTAKOS_BASE_PATH)
-BASE_ASTAKOS_PROXY_PATH = join_urls(BASE_PATH, BASE_ASTAKOS_PROXY_PATH)
-BASE_ASTAKOS_PROXY_PATH = BASE_ASTAKOS_PROXY_PATH.strip('/')
-
-PROXY_USER_SERVICES = getattr(settings, 'PITHOS_PROXY_USER_SERVICES', True)
+PITHOS_PREFIX = pithos_services['pithos_object-store']['prefix']
+PUBLIC_PREFIX = pithos_services['pithos_public']['prefix']
+UI_PREFIX = pithos_services['pithos_ui']['prefix']
 
 if not BASE_PATH.startswith("/"):
     BASE_PATH = "/" + BASE_PATH
 
 PITHOS_URL = get_public_endpoint(pithos_services, 'object-store', 'v1')
-ASTAKOS_UI_URL = get_public_endpoint(astakos_services, 'astakos_ui', '')
-
-if PROXY_USER_SERVICES:
-    ACCOUNT_URL = join_urls('/', BASE_ASTAKOS_PROXY_PATH,
-                            ASTAKOS_ACCOUNTS_PREFIX, 'v1.0')
-else:
-    ACCOUNT_URL = get_public_endpoint(astakos_services, 'account', 'v1.0')
-
-
-USER_CATALOG_URL = join_urls(ACCOUNT_URL, 'user_catalogs')
-FEEDBACK_URL = join_urls(ACCOUNT_URL, 'feedback')
-LOGIN_URL = join_urls(ASTAKOS_UI_URL, 'login?next=')
+PITHOS_UI_URL = get_public_endpoint(pithos_services, 'pithos_ui', '')
 
 AUTH_COOKIE_NAME = getattr(settings, 'PITHOS_UI_AUTH_COOKIE_NAME',
                            '_pithos2_a')
@@ -101,3 +70,16 @@ CLOUDBAR_ACTIVE_SERVICE = getattr(
     settings,
     'PITHOS_UI_CLOUDBAR_ACTIVE_SERVICE',
     'pithos')
+
+
+# --------------------------------------------------------------------
+# Process Astakos settings
+
+ASTAKOS_ACCOUNT_PROXY_PATH = join_urls(
+    '/', pithos_settings.ASTAKOS_ACCOUNT_PROXY_PATH)
+ASTAKOS_UI_PROXY_PATH = join_urls(
+    '/', pithos_settings.ASTAKOS_UI_PROXY_PATH)
+
+USER_CATALOG_URL = join_urls(ASTAKOS_ACCOUNT_PROXY_PATH, 'user_catalogs')
+FEEDBACK_URL = join_urls(ASTAKOS_ACCOUNT_PROXY_PATH, 'feedback')
+LOGIN_URL = join_urls(ASTAKOS_UI_PROXY_PATH, 'login?next=')