magic-removal: Moved django.utils.httpwrappers to django.http and updated dependencies.

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@1914 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Joseph Kocherhans 2006-01-11 21:45:38 +00:00
parent 8013f76a40
commit 36566e0ab1
30 changed files with 57 additions and 55 deletions

View File

@ -3,7 +3,7 @@ from django.contrib.admin.views.main import get_model_and_app
from django.contrib.admin.filterspecs import FilterSpec
from django.db import models
from django.db.models.query import handle_legacy_orderlist
from django.utils.httpwrappers import HttpResponse, HttpResponseRedirect
from django.http import HttpResponse, HttpResponseRedirect
from django.core.paginator import ObjectPaginator, InvalidPage
from django.core.extensions import DjangoContext as Context
from django.core.extensions import render_to_response

View File

@ -1,7 +1,7 @@
from django.core.extensions import DjangoContext, render_to_response
from django.conf.settings import SECRET_KEY
from django.contrib.auth.models import User, SESSION_KEY
from django.utils import httpwrappers
from django import http
from django.utils.translation import gettext_lazy
import base64, md5
import cPickle as pickle
@ -93,7 +93,7 @@ def staff_member_required(view_func):
return view_func(request, *args, **kwargs)
else:
request.session.delete_test_cookie()
return httpwrappers.HttpResponseRedirect(request.path)
return http.HttpResponseRedirect(request.path)
else:
return _display_login_form(request, ERROR_MESSAGE)

View File

@ -9,7 +9,7 @@ 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
from django.utils.html import escape, strip_tags
from django.utils.httpwrappers import HttpResponse, HttpResponseRedirect
from django.http import HttpResponse, HttpResponseRedirect
from django.utils.text import capfirst, get_text_list
import operator
from itertools import izip

View File

@ -6,7 +6,7 @@ from django.core import formfields, template
from django.core.exceptions import Http404, ImproperlyConfigured, ObjectDoesNotExist, PermissionDenied
from django.core.extensions import DjangoContext as Context
from django.db import models
from django.utils.httpwrappers import HttpResponse, HttpResponseRedirect
from django.http import HttpResponse, HttpResponseRedirect
from django.utils.text import capfirst, get_text_list
try:
from django.contrib.admin.models import LogEntry, ADDITION, CHANGE, DELETION

View File

@ -5,7 +5,7 @@ from django.core.extensions import DjangoContext as Context
from django.contrib.admin.views.stages.modify import render_change_form
from django.db import models
from django.utils.text import capfirst, get_text_list
from django.utils.httpwrappers import HttpResponse, HttpResponseRedirect
from django.http import HttpResponse, HttpResponseRedirect
from django.contrib.admin.views.decorators import staff_member_required
try:
from django.contrib.admin.models import LogEntry, ADDITION, CHANGE, DELETION

View File

@ -9,7 +9,7 @@ try:
from django.contrib.admin.models import LogEntry, ADDITION, CHANGE, DELETION
except ImportError:
raise ImproperlyConfigured, "You don't have 'django.contrib.admin' in INSTALLED_APPS."
from django.utils.httpwrappers import HttpResponse, HttpResponseRedirect
from django.http import HttpResponse, HttpResponseRedirect
def _nest_help(obj, depth, val):
current = obj

View File

@ -6,7 +6,7 @@ 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
from django.contrib.contenttypes.models import ContentType
from django.parts.auth.formfields import AuthenticationForm
from django.utils.httpwrappers import HttpResponseRedirect
from django.http import HttpResponseRedirect
from django.utils.text import normalize_newlines
from django.conf.settings import BANNED_IPS, COMMENTS_ALLOW_PROFANITIES, COMMENTS_SKETCHY_USERS_GROUP, COMMENTS_FIRST_FEW, SITE_ID
from django.utils.translation import ngettext

View File

@ -2,7 +2,7 @@ from django.core.extensions import DjangoContext, render_to_response
from django.core.exceptions import Http404
from django.models.comments import comments, moderatordeletions, userflags
from django.views.decorators.auth import login_required
from django.utils.httpwrappers import HttpResponseRedirect
from django.http import HttpResponseRedirect
from django.conf.settings import SITE_ID
def flag(request, comment_id):

View File

@ -1,7 +1,7 @@
from django.contrib.flatpages.models import FlatPage
from django.core import template_loader
from django.core.extensions import get_object_or_404, DjangoContext
from django.utils.httpwrappers import HttpResponse
from django.http import HttpResponse
from django.conf.settings import SITE_ID
DEFAULT_TEMPLATE = 'flatpages/default'

View File

@ -1,5 +1,5 @@
from django.contrib.redirects.models import Redirect
from django.utils import httpwrappers
from django import http
from django.conf.settings import APPEND_SLASH, SITE_ID
class RedirectFallbackMiddleware:
@ -20,8 +20,8 @@ class RedirectFallbackMiddleware:
pass
if r is not None:
if r == '':
return httpwrappers.HttpResponseGone()
return httpwrappers.HttpResponsePermanentRedirect(r.new_path)
return http.HttpResponseGone()
return http.HttpResponsePermanentRedirect(r.new_path)
# No redirect was found. Return the response.
return response

View File

@ -1,6 +1,6 @@
from django.contrib.syndication import feeds
from django.core.exceptions import Http404
from django.utils.httpwrappers import HttpResponse
from django.http import HttpResponse
def feed(request, url, feed_dict=None):
if not feed_dict:

View File

@ -5,7 +5,7 @@
from django.core.exceptions import Http404, ImproperlyConfigured
from django.core.template import Context, loader
from django.conf.settings import TEMPLATE_CONTEXT_PROCESSORS
from django.utils.httpwrappers import HttpResponse
from django.http import HttpResponse
_standard_context_processors = None

View File

@ -1,6 +1,6 @@
from django.core import signals
from django.dispatch import dispatcher
from django.utils import httpwrappers
from django import http
class BaseHandler:
def __init__(self):
@ -93,7 +93,7 @@ class BaseHandler:
callback, param_dict = resolver.resolve404()
return callback(request, **param_dict)
except exceptions.PermissionDenied:
return httpwrappers.HttpResponseForbidden('<h1>Permission denied</h1>')
return http.HttpResponseForbidden('<h1>Permission denied</h1>')
except: # Handle everything else, including SuspiciousOperation, etc.
if DEBUG:
return self.get_technical_error_response(request)

View File

@ -1,7 +1,8 @@
from django.core.handlers.base import BaseHandler
from django.core import signals
from django.dispatch import dispatcher
from django.utils import datastructures, httpwrappers
from django.utils import datastructures
from djang import http
from pprint import pformat
import os
@ -9,7 +10,7 @@ import os
# settings) until after ModPythonHandler has been called; otherwise os.environ
# won't be set up correctly (with respect to settings).
class ModPythonRequest(httpwrappers.HttpRequest):
class ModPythonRequest(http.HttpRequest):
def __init__(self, req):
self._req = req
self.path = req.uri
@ -25,9 +26,9 @@ class ModPythonRequest(httpwrappers.HttpRequest):
def _load_post_and_files(self):
"Populates self._post and self._files"
if self._req.headers_in.has_key('content-type') and self._req.headers_in['content-type'].startswith('multipart'):
self._post, self._files = httpwrappers.parse_file_upload(self._req.headers_in, self.raw_post_data)
self._post, self._files = http.parse_file_upload(self._req.headers_in, self.raw_post_data)
else:
self._post, self._files = httpwrappers.QueryDict(self.raw_post_data), datastructures.MultiValueDict()
self._post, self._files = http.QueryDict(self.raw_post_data), datastructures.MultiValueDict()
def _get_request(self):
if not hasattr(self, '_request'):
@ -36,7 +37,7 @@ class ModPythonRequest(httpwrappers.HttpRequest):
def _get_get(self):
if not hasattr(self, '_get'):
self._get = httpwrappers.QueryDict(self._req.args)
self._get = http.QueryDict(self._req.args)
return self._get
def _set_get(self, get):
@ -52,7 +53,7 @@ class ModPythonRequest(httpwrappers.HttpRequest):
def _get_cookies(self):
if not hasattr(self, '_cookies'):
self._cookies = httpwrappers.parse_cookie(self._req.headers_in.get('cookie', ''))
self._cookies = http.parse_cookie(self._req.headers_in.get('cookie', ''))
return self._cookies
def _set_cookies(self, cookies):

View File

@ -1,7 +1,8 @@
from django.core.handlers.base import BaseHandler
from django.core import signals
from django.dispatch import dispatcher
from django.utils import datastructures, httpwrappers
from django.utils import datastructures
from django import http
from pprint import pformat
# See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
@ -49,7 +50,7 @@ STATUS_CODE_TEXT = {
505: 'HTTP VERSION NOT SUPPORTED',
}
class WSGIRequest(httpwrappers.HttpRequest):
class WSGIRequest(http.HttpRequest):
def __init__(self, environ):
self.environ = environ
self.path = environ['PATH_INFO']
@ -70,11 +71,11 @@ class WSGIRequest(httpwrappers.HttpRequest):
if self.environ.get('CONTENT_TYPE', '').startswith('multipart'):
header_dict = dict([(k, v) for k, v in self.environ.items() if k.startswith('HTTP_')])
header_dict['Content-Type'] = self.environ.get('CONTENT_TYPE', '')
self._post, self._files = httpwrappers.parse_file_upload(header_dict, self.raw_post_data)
self._post, self._files = http.parse_file_upload(header_dict, self.raw_post_data)
else:
self._post, self._files = httpwrappers.QueryDict(self.raw_post_data), datastructures.MultiValueDict()
self._post, self._files = http.QueryDict(self.raw_post_data), datastructures.MultiValueDict()
else:
self._post, self._files = httpwrappers.QueryDict(''), datastructures.MultiValueDict()
self._post, self._files = http.QueryDict(''), datastructures.MultiValueDict()
def _get_request(self):
if not hasattr(self, '_request'):
@ -84,7 +85,7 @@ class WSGIRequest(httpwrappers.HttpRequest):
def _get_get(self):
if not hasattr(self, '_get'):
# The WSGI spec says 'QUERY_STRING' may be absent.
self._get = httpwrappers.QueryDict(self.environ.get('QUERY_STRING', ''))
self._get = http.QueryDict(self.environ.get('QUERY_STRING', ''))
return self._get
def _set_get(self, get):
@ -100,7 +101,7 @@ class WSGIRequest(httpwrappers.HttpRequest):
def _get_cookies(self):
if not hasattr(self, '_cookies'):
self._cookies = httpwrappers.parse_cookie(self.environ.get('HTTP_COOKIE', ''))
self._cookies = http.parse_cookie(self.environ.get('HTTP_COOKIE', ''))
return self._cookies
def _set_cookies(self, cookies):

View File

@ -1,7 +1,7 @@
from django.conf import settings
from django.core.cache import cache
from django.utils.cache import get_cache_key, learn_cache_key, patch_response_headers
from django.utils.httpwrappers import HttpResponseNotModified
from django.http import HttpResponseNotModified
class CacheMiddleware:
"""

View File

@ -1,5 +1,5 @@
from django.conf import settings
from django.utils import httpwrappers
from django import http
from django.core.mail import mail_managers
import md5, os
@ -27,7 +27,7 @@ class CommonMiddleware:
if request.META.has_key('HTTP_USER_AGENT'):
for user_agent_regex in settings.DISALLOWED_USER_AGENTS:
if user_agent_regex.search(request.META['HTTP_USER_AGENT']):
return httpwrappers.HttpResponseForbidden('<h1>Forbidden</h1>')
return http.HttpResponseForbidden('<h1>Forbidden</h1>')
# Check for a redirect based on settings.APPEND_SLASH and settings.PREPEND_WWW
old_url = [request.META.get('HTTP_HOST', ''), request.path]
@ -46,7 +46,7 @@ class CommonMiddleware:
newurl = new_url[1]
if request.GET:
newurl += '?' + request.GET.urlencode()
return httpwrappers.HttpResponsePermanentRedirect(newurl)
return http.HttpResponsePermanentRedirect(newurl)
return None
@ -69,7 +69,7 @@ class CommonMiddleware:
if settings.USE_ETAGS:
etag = md5.new(response.get_content_as_string(settings.DEFAULT_CHARSET)).hexdigest()
if request.META.get('HTTP_IF_NONE_MATCH') == etag:
response = httpwrappers.HttpResponseNotModified()
response = http.HttpResponseNotModified()
else:
response['ETag'] = etag

View File

@ -1,5 +1,5 @@
from django.conf import settings
from django.utils import httpwrappers
from django import http
class XViewMiddleware:
"""
@ -12,6 +12,6 @@ class XViewMiddleware:
documentation module to lookup the view function for an arbitrary page.
"""
if request.META['REQUEST_METHOD'] == 'HEAD' and request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS:
response = httpwrappers.HttpResponse()
response = http.HttpResponse()
response['X-View'] = "%s.%s" % (view_func.__module__, view_func.__name__)
return response

View File

@ -3,7 +3,7 @@ from django.core import formfields
from django.core.extensions import DjangoContext, render_to_response
from django.contrib.auth.models import SESSION_KEY
from django.contrib.sites.models import Site
from django.utils.httpwrappers import HttpResponse, HttpResponseRedirect
from django.http import HttpResponse, HttpResponseRedirect
REDIRECT_FIELD_NAME = 'next'
LOGIN_URL = '/accounts/login/'

View File

@ -1,7 +1,7 @@
from django.conf import settings
from django.core.template import Template, Context, TemplateDoesNotExist
from django.utils.html import escape
from django.utils.httpwrappers import HttpResponseServerError, HttpResponseNotFound
from django.http import HttpResponseServerError, HttpResponseNotFound
import inspect, os, re, sys
from itertools import count, izip
from os.path import dirname, join as pathjoin

View File

@ -4,7 +4,7 @@ Decorators for views based on HTTP headers.
from django.utils.decorators import decorator_from_middleware
from django.middleware.http import ConditionalGetMiddleware
from django.utils.httpwrappers import HttpResponseForbidden
from django.http import HttpResponseForbidden
conditional_page = decorator_from_middleware(ConditionalGetMiddleware)

View File

@ -2,7 +2,7 @@ from django.core.exceptions import Http404, ObjectDoesNotExist
from django.core.template import Context, loader
from django.contrib.contenttypes.models import ContentType
from django.contrib.sites.models import Site
from django.utils import httpwrappers
from django import http
def shortcut(request, content_type_id, object_id):
"Redirect to an object's page based on a content-type ID and an object ID."
@ -22,7 +22,7 @@ def shortcut(request, content_type_id, object_id):
# If the object actually defines a domain, we're done.
if absurl.startswith('http://'):
return httpwrappers.HttpResponseRedirect(absurl)
return http.HttpResponseRedirect(absurl)
object_domain = None
@ -45,8 +45,8 @@ def shortcut(request, content_type_id, object_id):
object_domain = Site.objects.get_current().domain
except Site.DoesNotExist:
# Finally, give up and use a URL without the domain name
return httpwrappers.HttpResponseRedirect(obj.get_absolute_url())
return httpwrappers.HttpResponseRedirect('http://%s%s' % (object_domain, obj.get_absolute_url()))
return http.HttpResponseRedirect(obj.get_absolute_url())
return http.HttpResponseRedirect('http://%s%s' % (object_domain, obj.get_absolute_url()))
def page_not_found(request, template_name='404'):
"""
@ -57,7 +57,7 @@ def page_not_found(request, template_name='404'):
Context: None
"""
t = loader.get_template(template_name)
return httpwrappers.HttpResponseNotFound(t.render(Context()))
return http.HttpResponseNotFound(t.render(Context()))
def server_error(request, template_name='500'):
"""
@ -67,4 +67,4 @@ def server_error(request, template_name='500'):
Context: None
"""
t = loader.get_template(template_name)
return httpwrappers.HttpResponseServerError(t.render(Context()))
return http.HttpResponseServerError(t.render(Context()))

View File

@ -5,7 +5,7 @@ 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.utils.httpwrappers import HttpResponse, HttpResponseRedirect
from django.http import HttpResponse, HttpResponseRedirect
from django.core.exceptions import Http404, ObjectDoesNotExist, ImproperlyConfigured
def create_object(request, app_label, module_name, template_name=None,

View File

@ -3,7 +3,7 @@ from django.core.exceptions import Http404, ObjectDoesNotExist
from django.core.extensions import DjangoContext
from django.core.xheaders import populate_xheaders
from django.models import get_module
from django.utils.httpwrappers import HttpResponse
from django.http import HttpResponse
import datetime, time
def archive_index(request, app_label, module_name, date_field, num_latest=15,

View File

@ -1,6 +1,6 @@
from django import models
from django.core.template import loader
from django.utils.httpwrappers import HttpResponse
from django.http import HttpResponse
from django.core.xheaders import populate_xheaders
from django.core.extensions import DjangoContext
from django.core.paginator import ObjectPaginator, InvalidPage

View File

@ -1,5 +1,5 @@
from django.core.extensions import DjangoContext, render_to_response
from django.utils.httpwrappers import HttpResponse, HttpResponsePermanentRedirect, HttpResponseGone
from django.http import HttpResponse, HttpResponsePermanentRedirect, HttpResponseGone
def direct_to_template(request, template, **kwargs):
"""

View File

@ -3,7 +3,7 @@ import os
import gettext as gettext_module
from django.utils import httpwrappers
from django import http
from django.utils.translation import check_for_language, activate, to_locale, get_language
from django.utils.text import javascript_quote
from django.conf import settings
@ -20,7 +20,7 @@ def set_language(request):
next = request.META.get('HTTP_REFERER', None)
if not next:
next = '/'
response = httpwrappers.HttpResponseRedirect(next)
response = http.HttpResponseRedirect(next)
if check_for_language(lang_code):
if hasattr(request, 'session'):
request.session['django_language'] = lang_code
@ -193,5 +193,5 @@ def javascript_catalog(request, domain='djangojs', packages=None):
src.append(LibFoot)
src.append(InterPolate)
src = ''.join(src)
return httpwrappers.HttpResponse(src, 'text/javascript')
return http.HttpResponse(src, 'text/javascript')

View File

@ -4,7 +4,7 @@ from django.core.template import Context, loader
from django.models.auth import User
from django.models.core import Site
from django.views.decorators.auth import login_required
from django.utils.httpwrappers import HttpResponseRedirect
from django.http import HttpResponseRedirect
class PasswordResetForm(formfields.Manipulator):
"A form that lets a user request a password reset"

View File

@ -4,7 +4,7 @@ import posixpath
import mimetypes
from django.core import template_loader
from django.core.exceptions import Http404, ImproperlyConfigured
from django.utils.httpwrappers import HttpResponse, HttpResponseRedirect
from django.http import HttpResponse, HttpResponseRedirect
from django.core.template import Template, Context, TemplateDoesNotExist
def serve(request, path, document_root=None, show_indexes=False):