Removed 'mimetype' arguments from a few places, as per deprecation TL.
This includes HttpResponse and co. __init__() methods, django.shortcuts.render_to_response() and the index(), sitemap() sitemap app views.
This commit is contained in:
parent
6ba69c8456
commit
8eadbc5a03
|
@ -19,13 +19,7 @@ def x_robots_tag(func):
|
||||||
@x_robots_tag
|
@x_robots_tag
|
||||||
def index(request, sitemaps,
|
def index(request, sitemaps,
|
||||||
template_name='sitemap_index.xml', content_type='application/xml',
|
template_name='sitemap_index.xml', content_type='application/xml',
|
||||||
sitemap_url_name='django.contrib.sitemaps.views.sitemap',
|
sitemap_url_name='django.contrib.sitemaps.views.sitemap'):
|
||||||
mimetype=None):
|
|
||||||
|
|
||||||
if mimetype:
|
|
||||||
warnings.warn("The mimetype keyword argument is deprecated, use "
|
|
||||||
"content_type instead", DeprecationWarning, stacklevel=2)
|
|
||||||
content_type = mimetype
|
|
||||||
|
|
||||||
req_protocol = 'https' if request.is_secure() else 'http'
|
req_protocol = 'https' if request.is_secure() else 'http'
|
||||||
req_site = get_current_site(request)
|
req_site = get_current_site(request)
|
||||||
|
@ -47,13 +41,7 @@ def index(request, sitemaps,
|
||||||
|
|
||||||
@x_robots_tag
|
@x_robots_tag
|
||||||
def sitemap(request, sitemaps, section=None,
|
def sitemap(request, sitemaps, section=None,
|
||||||
template_name='sitemap.xml', content_type='application/xml',
|
template_name='sitemap.xml', content_type='application/xml'):
|
||||||
mimetype=None):
|
|
||||||
|
|
||||||
if mimetype:
|
|
||||||
warnings.warn("The mimetype keyword argument is deprecated, use "
|
|
||||||
"content_type instead", DeprecationWarning, stacklevel=2)
|
|
||||||
content_type = mimetype
|
|
||||||
|
|
||||||
req_protocol = 'https' if request.is_secure() else 'http'
|
req_protocol = 'https' if request.is_secure() else 'http'
|
||||||
req_site = get_current_site(request)
|
req_site = get_current_site(request)
|
||||||
|
|
|
@ -98,7 +98,7 @@ class HttpResponseBase(six.Iterator):
|
||||||
status_code = 200
|
status_code = 200
|
||||||
reason_phrase = None # Use default reason phrase for status code.
|
reason_phrase = None # Use default reason phrase for status code.
|
||||||
|
|
||||||
def __init__(self, content_type=None, status=None, reason=None, mimetype=None):
|
def __init__(self, content_type=None, status=None, reason=None):
|
||||||
# _headers is a mapping of the lower-case name to the original case of
|
# _headers is a mapping of the lower-case name to the original case of
|
||||||
# the header (required for working with legacy systems) and the header
|
# the header (required for working with legacy systems) and the header
|
||||||
# value. Both the name of the header and its value are ASCII strings.
|
# value. Both the name of the header and its value are ASCII strings.
|
||||||
|
@ -108,11 +108,6 @@ class HttpResponseBase(six.Iterator):
|
||||||
# This parameter is set by the handler. It's necessary to preserve the
|
# This parameter is set by the handler. It's necessary to preserve the
|
||||||
# historical behavior of request_finished.
|
# historical behavior of request_finished.
|
||||||
self._handler_class = None
|
self._handler_class = None
|
||||||
if mimetype:
|
|
||||||
warnings.warn("Using mimetype keyword argument is deprecated, use"
|
|
||||||
" content_type instead",
|
|
||||||
DeprecationWarning, stacklevel=2)
|
|
||||||
content_type = mimetype
|
|
||||||
if not content_type:
|
if not content_type:
|
||||||
content_type = "%s; charset=%s" % (settings.DEFAULT_CONTENT_TYPE,
|
content_type = "%s; charset=%s" % (settings.DEFAULT_CONTENT_TYPE,
|
||||||
self._charset)
|
self._charset)
|
||||||
|
|
|
@ -20,12 +20,6 @@ def render_to_response(*args, **kwargs):
|
||||||
"""
|
"""
|
||||||
httpresponse_kwargs = {'content_type': kwargs.pop('content_type', None)}
|
httpresponse_kwargs = {'content_type': kwargs.pop('content_type', None)}
|
||||||
|
|
||||||
mimetype = kwargs.pop('mimetype', None)
|
|
||||||
if mimetype:
|
|
||||||
warnings.warn("The mimetype keyword argument is deprecated, use "
|
|
||||||
"content_type instead", DeprecationWarning, stacklevel=2)
|
|
||||||
httpresponse_kwargs['content_type'] = mimetype
|
|
||||||
|
|
||||||
return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
|
return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
|
||||||
|
|
||||||
def render(request, *args, **kwargs):
|
def render(request, *args, **kwargs):
|
||||||
|
|
|
@ -10,8 +10,7 @@ class ContentNotRenderedError(Exception):
|
||||||
class SimpleTemplateResponse(HttpResponse):
|
class SimpleTemplateResponse(HttpResponse):
|
||||||
rendering_attrs = ['template_name', 'context_data', '_post_render_callbacks']
|
rendering_attrs = ['template_name', 'context_data', '_post_render_callbacks']
|
||||||
|
|
||||||
def __init__(self, template, context=None, content_type=None, status=None,
|
def __init__(self, template, context=None, content_type=None, status=None):
|
||||||
mimetype=None):
|
|
||||||
# It would seem obvious to call these next two members 'template' and
|
# It would seem obvious to call these next two members 'template' and
|
||||||
# 'context', but those names are reserved as part of the test Client
|
# 'context', but those names are reserved as part of the test Client
|
||||||
# API. To avoid the name collision, we use tricky-to-debug problems
|
# API. To avoid the name collision, we use tricky-to-debug problems
|
||||||
|
@ -23,8 +22,7 @@ class SimpleTemplateResponse(HttpResponse):
|
||||||
# content argument doesn't make sense here because it will be replaced
|
# content argument doesn't make sense here because it will be replaced
|
||||||
# with rendered template so we always pass empty string in order to
|
# with rendered template so we always pass empty string in order to
|
||||||
# prevent errors and provide shorter signature.
|
# prevent errors and provide shorter signature.
|
||||||
super(SimpleTemplateResponse, self).__init__('', content_type, status,
|
super(SimpleTemplateResponse, self).__init__('', content_type, status)
|
||||||
mimetype)
|
|
||||||
|
|
||||||
# _is_rendered tracks whether the template and context has been baked
|
# _is_rendered tracks whether the template and context has been baked
|
||||||
# into a final response.
|
# into a final response.
|
||||||
|
@ -139,7 +137,7 @@ class TemplateResponse(SimpleTemplateResponse):
|
||||||
['_request', '_current_app']
|
['_request', '_current_app']
|
||||||
|
|
||||||
def __init__(self, request, template, context=None, content_type=None,
|
def __init__(self, request, template, context=None, content_type=None,
|
||||||
status=None, mimetype=None, current_app=None):
|
status=None, current_app=None):
|
||||||
# self.request gets over-written by django.test.client.Client - and
|
# self.request gets over-written by django.test.client.Client - and
|
||||||
# unlike context_data and template_name the _request should not
|
# unlike context_data and template_name the _request should not
|
||||||
# be considered part of the public API.
|
# be considered part of the public API.
|
||||||
|
@ -148,7 +146,7 @@ class TemplateResponse(SimpleTemplateResponse):
|
||||||
# having to avoid needing to create the RequestContext directly
|
# having to avoid needing to create the RequestContext directly
|
||||||
self._current_app = current_app
|
self._current_app = current_app
|
||||||
super(TemplateResponse, self).__init__(
|
super(TemplateResponse, self).__init__(
|
||||||
template, context, content_type, status, mimetype)
|
template, context, content_type, status)
|
||||||
|
|
||||||
def resolve_context(self, context):
|
def resolve_context(self, context):
|
||||||
"""Convert context data into a full RequestContext object
|
"""Convert context data into a full RequestContext object
|
||||||
|
|
|
@ -295,7 +295,7 @@ these changes.
|
||||||
:class:`~django.template.response.TemplateResponse`, will be removed.
|
:class:`~django.template.response.TemplateResponse`, will be removed.
|
||||||
``content_type`` should be used instead. This also applies to the
|
``content_type`` should be used instead. This also applies to the
|
||||||
:func:`~django.shortcuts.render_to_response` shortcut and
|
:func:`~django.shortcuts.render_to_response` shortcut and
|
||||||
the sitemamp views, :func:`~django.contrib.sitemaps.views.index` and
|
the sitemap views, :func:`~django.contrib.sitemaps.views.index` and
|
||||||
:func:`~django.contrib.sitemaps.views.sitemap`.
|
:func:`~django.contrib.sitemaps.views.sitemap`.
|
||||||
|
|
||||||
* When :class:`~django.http.HttpResponse` is instantiated with an iterator,
|
* When :class:`~django.http.HttpResponse` is instantiated with an iterator,
|
||||||
|
|
|
@ -82,8 +82,7 @@ Methods
|
||||||
deprecated), but since this is actually the value included in the HTTP
|
deprecated), but since this is actually the value included in the HTTP
|
||||||
``Content-Type`` header, it can also include the character set
|
``Content-Type`` header, it can also include the character set
|
||||||
encoding, which makes it more than just a MIME type specification. If
|
encoding, which makes it more than just a MIME type specification. If
|
||||||
``mimetype`` is specified (not ``None``), that value is used.
|
``content_type`` is specified, then its value is used. Otherwise,
|
||||||
Otherwise, ``content_type`` is used. If neither is given,
|
|
||||||
:setting:`DEFAULT_CONTENT_TYPE` is used.
|
:setting:`DEFAULT_CONTENT_TYPE` is used.
|
||||||
|
|
||||||
|
|
||||||
|
@ -175,8 +174,7 @@ Methods
|
||||||
deprecated), but since this is actually the value included in the HTTP
|
deprecated), but since this is actually the value included in the HTTP
|
||||||
``Content-Type`` header, it can also include the character set
|
``Content-Type`` header, it can also include the character set
|
||||||
encoding, which makes it more than just a MIME type specification. If
|
encoding, which makes it more than just a MIME type specification. If
|
||||||
``mimetype`` is specified (not ``None``), that value is used.
|
``content_type`` is specified, then its value is used. Otherwise,
|
||||||
Otherwise, ``content_type`` is used. If neither is given,
|
|
||||||
:setting:`DEFAULT_CONTENT_TYPE` is used.
|
:setting:`DEFAULT_CONTENT_TYPE` is used.
|
||||||
|
|
||||||
``current_app``
|
``current_app``
|
||||||
|
|
Loading…
Reference in New Issue