summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2013-01-31 13:39:29 +0100
committerAymeric Augustin <aymeric.augustin@m4x.org>2013-01-31 13:54:40 +0100
commit89cb771be7b53c40642872cdbedb15943bdf8e34 (patch)
tree43b9e7addfe0d5f2ad99a569507f4c19562e4aef /django
parentb2039d39d537340c1617f23d68b3f40f070e01db (diff)
Fixed #19692 -- Completed deprecation of mimetype in favor of content_type.
Thanks Tim for the report and initial patch.
Diffstat (limited to 'django')
-rw-r--r--django/contrib/sitemaps/views.py26
-rw-r--r--django/shortcuts/__init__.py10
2 files changed, 30 insertions, 6 deletions
diff --git a/django/contrib/sitemaps/views.py b/django/contrib/sitemaps/views.py
index cfe3aa66a9..c8d2f4dfa0 100644
--- a/django/contrib/sitemaps/views.py
+++ b/django/contrib/sitemaps/views.py
@@ -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", DeprecationWarning, 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", DeprecationWarning, 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)
diff --git a/django/shortcuts/__init__.py b/django/shortcuts/__init__.py
index 9f896347a4..21bd7a06d2 100644
--- a/django/shortcuts/__init__.py
+++ b/django/shortcuts/__init__.py
@@ -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", DeprecationWarning, stacklevel=2)
+ httpresponse_kwargs['content_type'] = mimetype
+
return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
def render(request, *args, **kwargs):