From a32f67967e4b1657fc35d9306ff342930719110d Mon Sep 17 00:00:00 2001 From: Gabriel Hurley Date: Tue, 6 Mar 2012 17:43:15 -0800 Subject: Minor extensibility improvements. * Allow exceptions.handle to include user-defined exception types. Fixes bug 948536. * Adds a wrapper around the form/table header/table in the base _data_table.html template for easier targeting/styling. * Moves the rest of the main nav templating into a single template for easier customization. Fixes bug 948508. Change-Id: I045c29744ee01f60b080f2c1bbdc79ea5acf1b86 --- horizon/exceptions.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'horizon/exceptions.py') 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): -- cgit v1.2.1