Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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.
  • Loading branch information...
commit 8eadbc5a03d06f5bfedfa3fad35ad0801d2ab6ff 1 parent 6ba69c8
Ramiro Morales authored
16  django/contrib/sitemaps/views.py
@@ -19,13 +19,7 @@ def inner(request, *args, **kwargs):
19 19
 @x_robots_tag
20 20
 def index(request, sitemaps,
21 21
           template_name='sitemap_index.xml', content_type='application/xml',
22  
-          sitemap_url_name='django.contrib.sitemaps.views.sitemap',
23  
-          mimetype=None):
24  
-
25  
-    if mimetype:
26  
-        warnings.warn("The mimetype keyword argument is deprecated, use "
27  
-            "content_type instead", DeprecationWarning, stacklevel=2)
28  
-        content_type = mimetype
  22
+          sitemap_url_name='django.contrib.sitemaps.views.sitemap'):
29 23
 
30 24
     req_protocol = 'https' if request.is_secure() else 'http'
31 25
     req_site = get_current_site(request)
@@ -47,13 +41,7 @@ def index(request, sitemaps,
47 41
 
48 42
 @x_robots_tag
49 43
 def sitemap(request, sitemaps, section=None,
50  
-            template_name='sitemap.xml', content_type='application/xml',
51  
-            mimetype=None):
52  
-
53  
-    if mimetype:
54  
-        warnings.warn("The mimetype keyword argument is deprecated, use "
55  
-            "content_type instead", DeprecationWarning, stacklevel=2)
56  
-        content_type = mimetype
  44
+            template_name='sitemap.xml', content_type='application/xml'):
57 45
 
58 46
     req_protocol = 'https' if request.is_secure() else 'http'
59 47
     req_site = get_current_site(request)
7  django/http/response.py
@@ -98,7 +98,7 @@ class HttpResponseBase(six.Iterator):
98 98
     status_code = 200
99 99
     reason_phrase = None        # Use default reason phrase for status code.
100 100
 
101  
-    def __init__(self, content_type=None, status=None, reason=None, mimetype=None):
  101
+    def __init__(self, content_type=None, status=None, reason=None):
102 102
         # _headers is a mapping of the lower-case name to the original case of
103 103
         # the header (required for working with legacy systems) and the header
104 104
         # value. Both the name of the header and its value are ASCII strings.
@@ -108,11 +108,6 @@ def __init__(self, content_type=None, status=None, reason=None, mimetype=None):
108 108
         # This parameter is set by the handler. It's necessary to preserve the
109 109
         # historical behavior of request_finished.
110 110
         self._handler_class = None
111  
-        if mimetype:
112  
-            warnings.warn("Using mimetype keyword argument is deprecated, use"
113  
-                          " content_type instead",
114  
-                          DeprecationWarning, stacklevel=2)
115  
-            content_type = mimetype
116 111
         if not content_type:
117 112
             content_type = "%s; charset=%s" % (settings.DEFAULT_CONTENT_TYPE,
118 113
                     self._charset)
6  django/shortcuts/__init__.py
@@ -20,12 +20,6 @@ def render_to_response(*args, **kwargs):
20 20
     """
21 21
     httpresponse_kwargs = {'content_type': kwargs.pop('content_type', None)}
22 22
 
23  
-    mimetype = kwargs.pop('mimetype', None)
24  
-    if mimetype:
25  
-        warnings.warn("The mimetype keyword argument is deprecated, use "
26  
-            "content_type instead", DeprecationWarning, stacklevel=2)
27  
-        httpresponse_kwargs['content_type'] = mimetype
28  
-
29 23
     return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
30 24
 
31 25
 def render(request, *args, **kwargs):
10  django/template/response.py
@@ -10,8 +10,7 @@ class ContentNotRenderedError(Exception):
10 10
 class SimpleTemplateResponse(HttpResponse):
11 11
     rendering_attrs = ['template_name', 'context_data', '_post_render_callbacks']
12 12
 
13  
-    def __init__(self, template, context=None, content_type=None, status=None,
14  
-            mimetype=None):
  13
+    def __init__(self, template, context=None, content_type=None, status=None):
15 14
         # It would seem obvious to call these next two members 'template' and
16 15
         # 'context', but those names are reserved as part of the test Client
17 16
         # API. To avoid the name collision, we use tricky-to-debug problems
@@ -23,8 +22,7 @@ def __init__(self, template, context=None, content_type=None, status=None,
23 22
         # content argument doesn't make sense here because it will be replaced
24 23
         # with rendered template so we always pass empty string in order to
25 24
         # prevent errors and provide shorter signature.
26  
-        super(SimpleTemplateResponse, self).__init__('', content_type, status,
27  
-                                                     mimetype)
  25
+        super(SimpleTemplateResponse, self).__init__('', content_type, status)
28 26
 
29 27
         # _is_rendered tracks whether the template and context has been baked
30 28
         # into a final response.
@@ -139,7 +137,7 @@ class TemplateResponse(SimpleTemplateResponse):
139 137
         ['_request', '_current_app']
140 138
 
141 139
     def __init__(self, request, template, context=None, content_type=None,
142  
-            status=None, mimetype=None, current_app=None):
  140
+            status=None, current_app=None):
143 141
         # self.request gets over-written by django.test.client.Client - and
144 142
         # unlike context_data and template_name the _request should not
145 143
         # be considered part of the public API.
@@ -148,7 +146,7 @@ def __init__(self, request, template, context=None, content_type=None,
148 146
         # having to avoid needing to create the RequestContext directly
149 147
         self._current_app = current_app
150 148
         super(TemplateResponse, self).__init__(
151  
-            template, context, content_type, status, mimetype)
  149
+            template, context, content_type, status)
152 150
 
153 151
     def resolve_context(self, context):
154 152
         """Convert context data into a full RequestContext object
2  docs/internals/deprecation.txt
@@ -295,7 +295,7 @@ these changes.
295 295
   :class:`~django.template.response.TemplateResponse`, will be removed.
296 296
   ``content_type`` should be used instead. This also applies to the
297 297
   :func:`~django.shortcuts.render_to_response` shortcut and
298  
-  the sitemamp views, :func:`~django.contrib.sitemaps.views.index` and
  298
+  the sitemap views, :func:`~django.contrib.sitemaps.views.index` and
299 299
   :func:`~django.contrib.sitemaps.views.sitemap`.
300 300
 
301 301
 * When :class:`~django.http.HttpResponse` is instantiated with an iterator,
6  docs/ref/template-response.txt
@@ -82,8 +82,7 @@ Methods
82 82
             deprecated), but since this is actually the value included in the HTTP
83 83
             ``Content-Type`` header, it can also include the character set
84 84
             encoding, which makes it more than just a MIME type specification. If
85  
-            ``mimetype`` is specified (not ``None``), that value is used.
86  
-            Otherwise, ``content_type`` is used. If neither is given,
  85
+            ``content_type`` is specified, then its value is used. Otherwise,
87 86
             :setting:`DEFAULT_CONTENT_TYPE` is used.
88 87
 
89 88
 
@@ -175,8 +174,7 @@ Methods
175 174
         deprecated), but since this is actually the value included in the HTTP
176 175
         ``Content-Type`` header, it can also include the character set
177 176
         encoding, which makes it more than just a MIME type specification. If
178  
-        ``mimetype`` is specified (not ``None``), that value is used.
179  
-        Otherwise, ``content_type`` is used. If neither is given,
  177
+        ``content_type`` is specified, then its value is used. Otherwise,
180 178
         :setting:`DEFAULT_CONTENT_TYPE` is used.
181 179
 
182 180
     ``current_app``

0 notes on commit 8eadbc5

Please sign in to comment.
Something went wrong with that request. Please try again.