Ticket #3349: patch_3349.diff
File patch_3349.diff, 10.4 KB (added by , 16 years ago) |
---|
-
django/conf/__init__.py
9 9 import os 10 10 import time # Needed for Windows 11 11 from django.conf import global_settings 12 from django.core.exceptions import wrap_and_raise 12 13 13 14 ENVIRONMENT_VARIABLE = "DJANGO_SETTINGS_MODULE" 14 15 … … 84 85 try: 85 86 mod = __import__(self.SETTINGS_MODULE, {}, {}, ['']) 86 87 except ImportError, e: 87 raise ImportError, "Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e)88 wrap_and_raise(ImportError("Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e))) 88 89 89 90 # Settings that should be converted into tuples if they're mistakenly entered 90 91 # as strings. -
django/core/urlresolvers.py
8 8 """ 9 9 10 10 from django.http import Http404 11 from django.core.exceptions import ImproperlyConfigured, ViewDoesNotExist 11 from django.core.exceptions import ImproperlyConfigured, ViewDoesNotExist, wrap_and_raise 12 12 from django.utils.encoding import iri_to_uri, force_unicode, smart_str 13 13 from django.utils.functional import memoize 14 14 import re … … 178 178 self._callback = get_callable(self._callback_str) 179 179 except ImportError, e: 180 180 mod_name, _ = get_mod_func(self._callback_str) 181 raise ViewDoesNotExist, "Could not import %s. Error was: %s" % (mod_name, str(e))181 wrap_and_raise(ViewDoesNotExist("Could not import %s. Error was: %s" % (mod_name, str(e)))) 182 182 except AttributeError, e: 183 183 mod_name, func_name = get_mod_func(self._callback_str) 184 184 raise ViewDoesNotExist, "Tried %s in module %s. Error was: %s" % (func_name, mod_name, str(e)) … … 252 252 except Exception, e: 253 253 # Either an invalid urlconf_name, such as "foo.bar.", or some 254 254 # kind of problem during the actual import. 255 raise ImproperlyConfigured, "Error while importing URLconf %r: %s" % (self.urlconf_name, e)255 wrap_and_raise(ImproperlyConfigured("Error while importing URLconf %r: %s" % (self.urlconf_name, e))) 256 256 return self._urlconf_module 257 257 urlconf_module = property(_get_urlconf_module) 258 258 … … 266 266 try: 267 267 return getattr(__import__(mod_name, {}, {}, ['']), func_name), {} 268 268 except (ImportError, AttributeError), e: 269 raise ViewDoesNotExist, "Tried %s. Error was: %s" % (callback, str(e))269 wrap_and_raise(ViewDoesNotExist("Tried %s. Error was: %s" % (callback, str(e)))) 270 270 271 271 def resolve404(self): 272 272 return self._resolve_special('404') -
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.dispatch import dispatcher 6 7 7 8 class BaseHandler(object): … … 33 34 try: 34 35 mod = __import__(mw_module, {}, {}, ['']) 35 36 except ImportError, e: 36 raise exceptions.ImproperlyConfigured, 'Error importing middleware %s: "%s"' % (mw_module, e)37 wrap_and_raise(exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e))) 37 38 try: 38 39 mw_class = getattr(mod, mw_classname) 39 40 except AttributeError: -
django/core/exceptions.py
32 32 """Some kind of problem with a model field.""" 33 33 pass 34 34 35 36 def wrap_and_raise(new_exception): 37 """ 38 Call from an except: block to raise a new exception, while keeping 39 the traceback info from the source exception. 40 41 new_exception is be the Exception (or subclass) instance to raise. 42 """ 43 import sys 44 exc_class, exc, tb = sys.exc_info() 45 46 if issubclass(exc_class, Exception): 47 raise new_exception.__class__, new_exception, tb 48 else: 49 raise new_exception -
django/contrib/auth/__init__.py
1 1 import datetime 2 from django.core.exceptions import ImproperlyConfigured 2 from django.core.exceptions import ImproperlyConfigured, wrap_and_raise 3 3 4 4 SESSION_KEY = '_auth_user_id' 5 5 BACKEND_SESSION_KEY = '_auth_user_backend' … … 11 11 try: 12 12 mod = __import__(module, {}, {}, [attr]) 13 13 except ImportError, e: 14 raise ImproperlyConfigured, 'Error importing authentication backend %s: "%s"' % (module, e)14 wrap_and_raise(ImproperlyConfigured('Error importing authentication backend %s: "%s"' % (module, e))) 15 15 except ValueError, e: 16 16 raise ImproperlyConfigured, 'Error importing authentication backends. Is AUTHENTICATION_BACKENDS a correctly defined list or tuple?' 17 17 try: -
django/template/__init__.py
51 51 import re 52 52 from inspect import getargspec 53 53 from django.conf import settings 54 from django.core.exceptions import wrap_and_raise 54 55 from django.template.context import Context, RequestContext, ContextPopException 55 56 from django.utils.itercompat import is_iterable 56 57 from django.utils.functional import curry, Promise … … 919 920 try: 920 921 mod = __import__(module_name, {}, {}, ['']) 921 922 except ImportError, e: 922 raise InvalidTemplateLibrary("Could not load template library from %s, %s" % (module_name, e))923 wrap_and_raise(InvalidTemplateLibrary("Could not load template library from %s, %s" % (module_name, e))) 923 924 try: 924 925 lib = mod.register 925 926 libraries[module_name] = lib -
django/template/loaders/app_directories.py
6 6 import os 7 7 8 8 from django.conf import settings 9 from django.core.exceptions import ImproperlyConfigured 9 from django.core.exceptions import ImproperlyConfigured, wrap_and_raise 10 10 from django.template import TemplateDoesNotExist 11 11 from django.utils._os import safe_join 12 12 … … 24 24 else: 25 25 mod = getattr(__import__(m, {}, {}, [a]), a) 26 26 except ImportError, e: 27 raise ImproperlyConfigured, 'ImportError %s: %s' % (app, e.args[0])27 wrap_and_raise(ImproperlyConfigured('ImportError %s: %s' % (app, e.args[0]))) 28 28 template_dir = os.path.join(os.path.dirname(mod.__file__), 'templates') 29 29 if os.path.isdir(template_dir): 30 30 app_template_dirs.append(template_dir) -
django/template/defaulttags.py
12 12 from django.template import TemplateSyntaxError, VariableDoesNotExist, BLOCK_TAG_START, BLOCK_TAG_END, VARIABLE_TAG_START, VARIABLE_TAG_END, SINGLE_BRACE_START, SINGLE_BRACE_END, COMMENT_TAG_START, COMMENT_TAG_END 13 13 from django.template import get_library, Library, InvalidTemplateLibrary 14 14 from django.conf import settings 15 from django.core.exceptions import wrap_and_raise 15 16 from django.utils.encoding import smart_str, smart_unicode 16 17 from django.utils.itercompat import groupby 17 18 from django.utils.safestring import mark_safe … … 853 854 lib = get_library("django.templatetags.%s" % taglib) 854 855 parser.add_library(lib) 855 856 except InvalidTemplateLibrary, e: 856 raiseTemplateSyntaxError("'%s' is not a valid tag library: %s" %857 (taglib, e)) 857 wrap_and_raise(TemplateSyntaxError("'%s' is not a valid tag library: %s" % 858 (taglib, e))) 858 859 return LoadNode() 859 860 load = register.tag(load) 860 861 -
django/template/context.py
1 1 from django.conf import settings 2 from django.core.exceptions import ImproperlyConfigured 2 from django.core.exceptions import ImproperlyConfigured, wrap_and_raise 3 3 4 4 _standard_context_processors = None 5 5 … … 77 77 try: 78 78 mod = __import__(module, {}, {}, [attr]) 79 79 except ImportError, e: 80 raise ImproperlyConfigured('Error importing request processor module %s: "%s"' % (module, e))80 wrap_and_raise(ImproperlyConfigured('Error importing request processor module %s: "%s"' % (module, e))) 81 81 try: 82 82 func = getattr(mod, attr) 83 83 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.conf import settings 26 26 … … 53 53 try: 54 54 mod = __import__(module, globals(), locals(), [attr]) 55 55 except ImportError, e: 56 raise ImproperlyConfigured, 'Error importing template source loader %s: "%s"' % (module, e)56 wrap_and_raise(ImproperlyConfigured('Error importing template source loader %s: "%s"' % (module, e))) 57 57 try: 58 58 func = getattr(mod, attr) 59 59 except AttributeError: