diff --git a/horizon/base.py b/horizon/base.py index ca5433ba3..3a778531d 100644 --- a/horizon/base.py +++ b/horizon/base.py @@ -49,6 +49,9 @@ HORIZON_CONFIG = { # Name of a default dashboard; defaults to first alphabetically if None 'default_dashboard': None, 'user_home': None, + 'exceptions': {'unauthorized': [], + 'not_found': [], + 'recoverable': []} } diff --git a/horizon/exceptions.py b/horizon/exceptions.py index cc1c93d04..8e27da74f 100644 --- a/horizon/exceptions.py +++ b/horizon/exceptions.py @@ -21,6 +21,7 @@ Exceptions raised by the Horizon code and the machinery for handling them. import logging import sys +from django.conf import settings from django.contrib import messages from django.utils.translation import ugettext as _ from cloudfiles import errors as swiftclient @@ -107,6 +108,10 @@ class HandledException(HorizonException): self.wrapped = wrapped +HORIZON_CONFIG = getattr(settings, "HORIZON_CONFIG", {}) +EXCEPTION_CONFIG = HORIZON_CONFIG.get("exceptions", {}) + + UNAUTHORIZED = (keystoneclient.Unauthorized, keystoneclient.Forbidden, novaclient.Unauthorized, @@ -115,12 +120,15 @@ UNAUTHORIZED = (keystoneclient.Unauthorized, glanceclient.NotAuthorized, swiftclient.AuthenticationFailed, swiftclient.AuthenticationError) +UNAUTHORIZED += tuple(EXCEPTION_CONFIG.get('unauthorized', [])) NOT_FOUND = (keystoneclient.NotFound, novaclient.NotFound, glanceclient.NotFound, swiftclient.NoSuchContainer, swiftclient.NoSuchObject) +NOT_FOUND += tuple(EXCEPTION_CONFIG.get('not_found', [])) + # NOTE(gabriel): This is very broad, and may need to be dialed in. RECOVERABLE = (keystoneclient.ClientException, @@ -128,6 +136,7 @@ RECOVERABLE = (keystoneclient.ClientException, glanceclient.GlanceException, swiftclient.Error, AlreadyExists) +RECOVERABLE += tuple(EXCEPTION_CONFIG.get('recoverable', [])) def handle(request, message=None, redirect=None, ignore=False, escalate=False): diff --git a/horizon/templates/horizon/_nav_list.html b/horizon/templates/horizon/_nav_list.html index dff8dcfaa..a56a5d2fb 100644 --- a/horizon/templates/horizon/_nav_list.html +++ b/horizon/templates/horizon/_nav_list.html @@ -1,9 +1,13 @@ -{% load horizon %} -{% for component in components %} +{% load horizon i18n %} +