Ticket #3349: 3349_r11897.diff
File 3349_r11897.diff, 9.8 KB (added by , 15 years ago) |
---|
-
django/conf/__init__.py
11 11 import time # Needed for Windows 12 12 13 13 from django.conf import global_settings 14 from django.core.exceptions import wrap_and_raise 14 15 from django.utils.functional import LazyObject 15 16 from django.utils import importlib 16 17 … … 72 73 try: 73 74 mod = importlib.import_module(self.SETTINGS_MODULE) 74 75 except ImportError, e: 75 raise ImportError, "Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e)76 wrap_and_raise(ImportError("Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e))) 76 77 77 78 # Settings that should be converted into tuples if they're mistakenly entered 78 79 # as strings. -
django/core/urlresolvers.py
11 11 12 12 from django.http import Http404 13 13 from django.conf import settings 14 from django.core.exceptions import ImproperlyConfigured, ViewDoesNotExist 14 from django.core.exceptions import ImproperlyConfigured, ViewDoesNotExist, wrap_and_raise 15 15 from django.utils.datastructures import MultiValueDict 16 16 from django.utils.encoding import iri_to_uri, force_unicode, smart_str 17 17 from django.utils.functional import memoize … … 135 135 self._callback = get_callable(self._callback_str) 136 136 except ImportError, e: 137 137 mod_name, _ = get_mod_func(self._callback_str) 138 raise ViewDoesNotExist, "Could not import %s. Error was: %s" % (mod_name, str(e))138 wrap_and_raise(ViewDoesNotExist("Could not import %s. Error was: %s" % (mod_name, str(e)))) 139 139 except AttributeError, e: 140 140 mod_name, func_name = get_mod_func(self._callback_str) 141 raise ViewDoesNotExist, "Tried %s in module %s. Error was: %s" % (func_name, mod_name, str(e))141 wrap_and_raise(ViewDoesNotExist("Tried %s in module %s. Error was: %s" % (func_name, mod_name, str(e)))) 142 142 return self._callback 143 143 callback = property(_get_callback) 144 144 -
django/core/handlers/base.py
2 2 3 3 from django import http 4 4 from django.core import signals 5 from django.core.exceptions import wrap_and_raise 5 6 from django.utils.encoding import force_unicode 6 7 from django.utils.importlib import import_module 7 8 … … 34 35 try: 35 36 dot = middleware_path.rindex('.') 36 37 except ValueError: 37 raise exceptions.ImproperlyConfigured, '%s isn\'t a middleware module' % middleware_path38 wrap_and_raise(exceptions.ImproperlyConfigured('%s isn\'t a middleware module' % middleware_path)) 38 39 mw_module, mw_classname = middleware_path[:dot], middleware_path[dot+1:] 39 40 try: 40 41 mod = import_module(mw_module) -
django/core/exceptions.py
35 35 class ValidationError(Exception): 36 36 """An error while validating data.""" 37 37 pass 38 39 def wrap_and_raise(new_exception): 40 """ 41 Call from an except: block to raise a new exception, while keeping 42 the traceback info from the source exception. 43 44 new_exception is be the Exception (or subclass) instance to raise. 45 """ 46 import sys 47 exc_class, exc, tb = sys.exc_info() 48 49 if issubclass(exc_class, Exception): 50 raise new_exception.__class__, new_exception, tb 51 else: 52 raise new_exception 53 -
django/contrib/auth/__init__.py
1 1 import datetime 2 2 from warnings import warn 3 from django.core.exceptions import ImproperlyConfigured 3 from django.core.exceptions import ImproperlyConfigured, wrap_and_raise 4 4 from django.utils.importlib import import_module 5 5 6 6 SESSION_KEY = '_auth_user_id' … … 13 13 try: 14 14 mod = import_module(module) 15 15 except ImportError, e: 16 raise ImproperlyConfigured, 'Error importing authentication backend %s: "%s"' % (module, e)16 wrap_and_raise(ImproperlyConfigured('Error importing authentication backend %s: "%s"' % (module, e))) 17 17 except ValueError, e: 18 18 raise ImproperlyConfigured, 'Error importing authentication backends. Is AUTHENTICATION_BACKENDS a correctly defined list or tuple?' 19 19 try: -
django/template/__init__.py
52 52 from inspect import getargspec 53 53 54 54 from django.conf import settings 55 from django.core.exceptions import wrap_and_raise 55 56 from django.template.context import Context, RequestContext, ContextPopException 56 57 from django.utils.importlib import import_module 57 58 from django.utils.itercompat import is_iterable … … 970 971 try: 971 972 mod = import_module(module_name) 972 973 except ImportError, e: 973 raise InvalidTemplateLibrary("Could not load template library from %s, %s" % (module_name, e))974 wrap_and_raise(InvalidTemplateLibrary("Could not load template library from %s, %s" % (module_name, e))) 974 975 try: 975 976 lib = mod.register 976 977 libraries[module_name] = lib -
django/template/loaders/app_directories.py
7 7 import sys 8 8 9 9 from django.conf import settings 10 from django.core.exceptions import ImproperlyConfigured 10 from django.core.exceptions import ImproperlyConfigured, wrap_and_raise 11 11 from django.template import TemplateDoesNotExist 12 12 from django.template.loader import BaseLoader 13 13 from django.utils._os import safe_join … … 20 20 try: 21 21 mod = import_module(app) 22 22 except ImportError, e: 23 raise ImproperlyConfigured, 'ImportError %s: %s' % (app, e.args[0])23 wrap_and_raise(ImproperlyConfigured('ImportError %s: %s' % (app, e.args[0]))) 24 24 template_dir = os.path.join(os.path.dirname(mod.__file__), 'templates') 25 25 if os.path.isdir(template_dir): 26 26 app_template_dirs.append(template_dir.decode(fs_encoding)) -
django/template/defaulttags.py
13 13 from django.template import get_library, Library, InvalidTemplateLibrary 14 14 from django.template.smartif import IfParser, Literal 15 15 from django.conf import settings 16 from django.core.exceptions import wrap_and_raise 16 17 from django.utils.encoding import smart_str, smart_unicode 17 18 from django.utils.itercompat import groupby 18 19 from django.utils.safestring import mark_safe … … 924 925 lib = get_library("django.templatetags.%s" % taglib) 925 926 parser.add_library(lib) 926 927 except InvalidTemplateLibrary, e: 927 raiseTemplateSyntaxError("'%s' is not a valid tag library: %s" %928 (taglib, e)) 928 wrap_and_raise(TemplateSyntaxError("'%s' is not a valid tag library: %s" % 929 (taglib, e))) 929 930 return LoadNode() 930 931 load = register.tag(load) 931 932 -
django/template/context.py
1 from django.core.exceptions import ImproperlyConfigured 1 from django.core.exceptions import ImproperlyConfigured, wrap_and_raise 2 2 from django.utils.importlib import import_module 3 3 4 4 # Cache of actual callables. … … 123 123 try: 124 124 mod = import_module(module) 125 125 except ImportError, e: 126 raise ImproperlyConfigured('Error importing request processor module %s: "%s"' % (module, e))126 wrap_and_raise(ImproperlyConfigured('Error importing request processor module %s: "%s"' % (module, e))) 127 127 try: 128 128 func = getattr(mod, attr) 129 129 except AttributeError: -
django/template/loader.py
20 20 # Python eggs) sets is_usable to False if the "pkg_resources" module isn't 21 21 # installed, because pkg_resources is necessary to read eggs. 22 22 23 from django.core.exceptions import ImproperlyConfigured 23 from django.core.exceptions import ImproperlyConfigured, wrap_and_raise 24 24 from django.template import Origin, Template, Context, TemplateDoesNotExist, add_to_builtins 25 25 from django.utils.importlib import import_module 26 26 from django.conf import settings … … 81 81 try: 82 82 mod = import_module(module) 83 83 except ImportError: 84 raise ImproperlyConfigured('Error importing template source loader %s: "%s"' % (loader, e))84 wrap_and_raise(ImproperlyConfigured('Error importing template source loader %s: "%s"' % (loader, e))) 85 85 try: 86 86 TemplateLoader = getattr(mod, attr) 87 87 except AttributeError, e: