1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

[1.5.x] Fixed #19692 -- Completed deprecation of mimetype in favor of content_type.

Thanks Tim for the report and initial patch.

Backport of 89cb771 from master.
This commit is contained in:
Aymeric Augustin
2013-01-31 13:39:29 +01:00
parent 256352a790
commit 11ec0253ab
11 changed files with 81 additions and 40 deletions

View File

@@ -1,3 +1,5 @@
import warnings
from django.contrib.sites.models import get_current_site
from django.core import urlresolvers
from django.core.paginator import EmptyPage, PageNotAnInteger
@@ -6,8 +8,15 @@ from django.template.response import TemplateResponse
from django.utils import six
def index(request, sitemaps,
template_name='sitemap_index.xml', mimetype='application/xml',
sitemap_url_name='django.contrib.sitemaps.views.sitemap'):
template_name='sitemap_index.xml', content_type='application/xml',
sitemap_url_name='django.contrib.sitemaps.views.sitemap',
mimetype=None):
if mimetype:
warnings.warn("The mimetype keyword argument is deprecated, use "
"content_type instead", PendingDeprecationWarning, stacklevel=2)
content_type = mimetype
req_protocol = 'https' if request.is_secure() else 'http'
req_site = get_current_site(request)
@@ -24,10 +33,17 @@ def index(request, sitemaps,
sites.append('%s?p=%s' % (absolute_url, page))
return TemplateResponse(request, template_name, {'sitemaps': sites},
content_type=mimetype)
content_type=content_type)
def sitemap(request, sitemaps, section=None,
template_name='sitemap.xml', mimetype='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", PendingDeprecationWarning, stacklevel=2)
content_type = mimetype
req_protocol = 'https' if request.is_secure() else 'http'
req_site = get_current_site(request)
@@ -51,4 +67,4 @@ def sitemap(request, sitemaps, section=None,
except PageNotAnInteger:
raise Http404("No page '%s'" % page)
return TemplateResponse(request, template_name, {'urlset': urls},
content_type=mimetype)
content_type=content_type)

View File

@@ -3,6 +3,7 @@ This module collects helper functions and classes that "span" multiple levels
of MVC. In other words, these functions/classes introduce controlled coupling
for convenience's sake.
"""
import warnings
from django.template import loader, RequestContext
from django.http import HttpResponse, Http404
@@ -17,7 +18,14 @@ def render_to_response(*args, **kwargs):
Returns a HttpResponse whose content is filled with the result of calling
django.template.loader.render_to_string() with the passed arguments.
"""
httpresponse_kwargs = {'content_type': kwargs.pop('mimetype', 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", PendingDeprecationWarning, stacklevel=2)
httpresponse_kwargs['content_type'] = mimetype
return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
def render(request, *args, **kwargs):