diff --git a/django/contrib/admin/views/doc.py b/django/contrib/admin/views/doc.py index d14e998b9a..34a945a60e 100644 --- a/django/contrib/admin/views/doc.py +++ b/django/contrib/admin/views/doc.py @@ -3,7 +3,8 @@ from django.conf import settings from django.contrib.admin.views.decorators import staff_member_required from django.db import models from django.core.extensions import DjangoContext, render_to_response -from django.core.exceptions import Http404, ViewDoesNotExist +from django.core.exceptions import ViewDoesNotExist +from django.http import Http404 from django.core import template, urlresolvers from django.contrib.admin import utils from django.contrib.sites.models import Site diff --git a/django/contrib/admin/views/main.py b/django/contrib/admin/views/main.py index 8e55dc98c4..c1f12039cc 100644 --- a/django/contrib/admin/views/main.py +++ b/django/contrib/admin/views/main.py @@ -4,7 +4,8 @@ from django.contrib.admin.views.decorators import staff_member_required from django.core import formfields, template from django.core.template import loader from django.db import models -from django.core.exceptions import Http404, ImproperlyConfigured, ObjectDoesNotExist, PermissionDenied +from django.http import Http404 +from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist, PermissionDenied from django.core.extensions import DjangoContext as Context from django.core.extensions import get_object_or_404, render_to_response from django.utils import dateformat diff --git a/django/contrib/admin/views/stages/add.py b/django/contrib/admin/views/stages/add.py index 31c018daf3..ffbfd67a0c 100644 --- a/django/contrib/admin/views/stages/add.py +++ b/django/contrib/admin/views/stages/add.py @@ -3,7 +3,8 @@ from django.contrib.admin.views.decorators import staff_member_required from django.contrib.admin.views.main import get_model_and_app from django.contrib.admin.views.stages.modify import render_change_form from django.core import formfields, template -from django.core.exceptions import Http404, ImproperlyConfigured, ObjectDoesNotExist, PermissionDenied +from django.http import Http404 +from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist, PermissionDenied from django.core.extensions import DjangoContext as Context from django.db import models from django.http import HttpResponse, HttpResponseRedirect diff --git a/django/contrib/admin/views/stages/change.py b/django/contrib/admin/views/stages/change.py index c8b3adcbf6..26d578eed5 100644 --- a/django/contrib/admin/views/stages/change.py +++ b/django/contrib/admin/views/stages/change.py @@ -1,6 +1,7 @@ from django.contrib.admin.views.main import get_model_and_app from django.core import formfields, template -from django.core.exceptions import Http404, ImproperlyConfigured, ObjectDoesNotExist, PermissionDenied +from django.http import Http404 +from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist, PermissionDenied from django.core.extensions import DjangoContext as Context from django.contrib.admin.views.stages.modify import render_change_form from django.db import models diff --git a/django/contrib/comments/views/comments.py b/django/contrib/comments/views/comments.py index eeb279a5aa..00d89e28b2 100644 --- a/django/contrib/comments/views/comments.py +++ b/django/contrib/comments/views/comments.py @@ -1,6 +1,7 @@ from django.core import formfields, validators from django.core.mail import mail_admins, mail_managers -from django.core.exceptions import Http404, ObjectDoesNotExist +from django.http import Http404 +from django.core.exceptions import ObjectDoesNotExist from django.core.extensions import DjangoContext, render_to_response from django.contrib.auth.models import SESSION_KEY from django.contrib.comments.models import Comment, FreeComment, PHOTOS_REQUIRED, PHOTOS_OPTIONAL, RATINGS_REQUIRED, RATINGS_OPTIONAL, IS_PUBLIC diff --git a/django/contrib/comments/views/karma.py b/django/contrib/comments/views/karma.py index 9db68d69f1..530271e857 100644 --- a/django/contrib/comments/views/karma.py +++ b/django/contrib/comments/views/karma.py @@ -1,4 +1,4 @@ -from django.core.exceptions import Http404 +from django.http import Http404 from django.core.extensions import DjangoContext, render_to_response from django.models.comments import comments, karma diff --git a/django/contrib/comments/views/userflags.py b/django/contrib/comments/views/userflags.py index baa2d42538..e58c3c1682 100644 --- a/django/contrib/comments/views/userflags.py +++ b/django/contrib/comments/views/userflags.py @@ -1,5 +1,5 @@ from django.core.extensions import DjangoContext, render_to_response -from django.core.exceptions import Http404 +from django.http import Http404 from django.models.comments import comments, moderatordeletions, userflags from django.views.decorators.auth import login_required from django.http import HttpResponseRedirect diff --git a/django/contrib/flatpages/middleware.py b/django/contrib/flatpages/middleware.py index c6f286563d..2aedf481e5 100644 --- a/django/contrib/flatpages/middleware.py +++ b/django/contrib/flatpages/middleware.py @@ -1,5 +1,5 @@ from django.contrib.flatpages.views import flatpage -from django.core.extensions import Http404 +from django.http import Http404 from django.conf.settings import DEBUG class FlatpageFallbackMiddleware: diff --git a/django/contrib/syndication/views.py b/django/contrib/syndication/views.py index 2de5f886b1..621665d4d4 100644 --- a/django/contrib/syndication/views.py +++ b/django/contrib/syndication/views.py @@ -1,6 +1,5 @@ from django.contrib.syndication import feeds -from django.core.exceptions import Http404 -from django.http import HttpResponse +from django.http import HttpResponse, Http404 def feed(request, url, feed_dict=None): if not feed_dict: diff --git a/django/core/exceptions.py b/django/core/exceptions.py index 297262f9b6..f22f67c261 100644 --- a/django/core/exceptions.py +++ b/django/core/exceptions.py @@ -1,8 +1,5 @@ "Global Django exceptions" -class Http404(Exception): - pass - class ObjectDoesNotExist(Exception): "The requested object does not exist" silent_variable_failure = True diff --git a/django/core/extensions.py b/django/core/extensions.py index 09e7c20242..62c1407a62 100644 --- a/django/core/extensions.py +++ b/django/core/extensions.py @@ -2,10 +2,10 @@ # of MVC. In other words, these functions/classes introduce controlled coupling # for convenience's sake. -from django.core.exceptions import Http404, ImproperlyConfigured +from django.core.exceptions import ImproperlyConfigured from django.core.template import Context, loader from django.conf.settings import TEMPLATE_CONTEXT_PROCESSORS -from django.http import HttpResponse +from django.http import HttpResponse, Http404 _standard_context_processors = None diff --git a/django/core/handlers/base.py b/django/core/handlers/base.py index 6e8cb040f6..9c30772baf 100644 --- a/django/core/handlers/base.py +++ b/django/core/handlers/base.py @@ -86,7 +86,7 @@ class BaseHandler: raise ValueError, "The view %s.%s didn't return an HttpResponse object." % (callback.__module__, callback.func_name) return response - except exceptions.Http404, e: + except http.Http404, e: if DEBUG: return self.get_technical_error_response(request, is404=True, exception=e) else: diff --git a/django/core/urlresolvers.py b/django/core/urlresolvers.py index 9582dd4d81..e11b63e977 100644 --- a/django/core/urlresolvers.py +++ b/django/core/urlresolvers.py @@ -7,7 +7,8 @@ a string) and returns a tuple in this format: (view_function, function_args, function_kwargs) """ -from django.core.exceptions import Http404, ImproperlyConfigured, ViewDoesNotExist +from django.http import Http404 +from django.core.exceptions import ImproperlyConfigured, ViewDoesNotExist import re class Resolver404(Http404): diff --git a/django/http/__init__.py b/django/http/__init__.py index 6fda8ad570..3178a438ea 100644 --- a/django/http/__init__.py +++ b/django/http/__init__.py @@ -9,6 +9,9 @@ try: except ImportError: from cgi import parse_qsl +class Http404(Exception): + pass + class HttpRequest(object): # needs to be new-style class because subclasses define "property"s "A basic HTTP request" def __init__(self): diff --git a/django/views/defaults.py b/django/views/defaults.py index c601fa0255..5287963d0f 100644 --- a/django/views/defaults.py +++ b/django/views/defaults.py @@ -1,4 +1,4 @@ -from django.core.exceptions import Http404, ObjectDoesNotExist +from django.core.exceptions import ObjectDoesNotExist from django.core.template import Context, loader from django.contrib.contenttypes.models import ContentType from django.contrib.sites.models import Site @@ -11,11 +11,11 @@ def shortcut(request, content_type_id, object_id): content_type = ContentType.objects.get_object(pk=content_type_id) obj = content_type.get_object_for_this_type(pk=object_id) except ObjectDoesNotExist: - raise Http404, "Content type %s object %s doesn't exist" % (content_type_id, object_id) + raise http.Http404, "Content type %s object %s doesn't exist" % (content_type_id, object_id) try: absurl = obj.get_absolute_url() except AttributeError: - raise Http404, "%s objects don't have get_absolute_url() methods" % content_type.name + raise http.Http404, "%s objects don't have get_absolute_url() methods" % content_type.name # Try to figure out the object's domain, so we can do a cross-site redirect # if necessary. diff --git a/django/views/generic/create_update.py b/django/views/generic/create_update.py index 7d326ade0c..3a1d4f76d4 100644 --- a/django/views/generic/create_update.py +++ b/django/views/generic/create_update.py @@ -5,8 +5,8 @@ from django.core import formfields, meta from django.views.auth.login import redirect_to_login from django.core.extensions import DjangoContext from django.core.paginator import ObjectPaginator, InvalidPage -from django.http import HttpResponse, HttpResponseRedirect -from django.core.exceptions import Http404, ObjectDoesNotExist, ImproperlyConfigured +from django.http import Http404, HttpResponse, HttpResponseRedirect +from django.core.exceptions import ObjectDoesNotExist, ImproperlyConfigured def create_object(request, app_label, module_name, template_name=None, template_loader=loader, extra_context={}, post_save_redirect=None, diff --git a/django/views/generic/date_based.py b/django/views/generic/date_based.py index 19ef0a9a35..02a572d2c4 100644 --- a/django/views/generic/date_based.py +++ b/django/views/generic/date_based.py @@ -1,9 +1,9 @@ from django.core.template import loader -from django.core.exceptions import Http404, ObjectDoesNotExist +from django.core.exceptions import ObjectDoesNotExist from django.core.extensions import DjangoContext from django.core.xheaders import populate_xheaders from django.models import get_module -from django.http import HttpResponse +from django.http import Http404, HttpResponse import datetime, time def archive_index(request, app_label, module_name, date_field, num_latest=15, diff --git a/django/views/generic/list_detail.py b/django/views/generic/list_detail.py index dd961bb51e..2600627f9c 100644 --- a/django/views/generic/list_detail.py +++ b/django/views/generic/list_detail.py @@ -1,10 +1,10 @@ from django import models from django.core.template import loader -from django.http import HttpResponse +from django.http import Http404, HttpResponse from django.core.xheaders import populate_xheaders from django.core.extensions import DjangoContext from django.core.paginator import ObjectPaginator, InvalidPage -from django.core.exceptions import Http404, ObjectDoesNotExist +from django.core.exceptions import ObjectDoesNotExist def object_list(request, app_label, module_name, paginate_by=None, allow_empty=False, template_name=None, template_loader=loader, extra_lookup_kwargs={}, diff --git a/django/views/static.py b/django/views/static.py index f02e30f584..cde95f4578 100644 --- a/django/views/static.py +++ b/django/views/static.py @@ -3,8 +3,8 @@ import urllib import posixpath import mimetypes from django.core import template_loader -from django.core.exceptions import Http404, ImproperlyConfigured -from django.http import HttpResponse, HttpResponseRedirect +from django.core.exceptions import ImproperlyConfigured +from django.http import Http404, HttpResponse, HttpResponseRedirect from django.core.template import Template, Context, TemplateDoesNotExist def serve(request, path, document_root=None, show_indexes=False):