[PATCH] Replace 'mimetype' with 'content_type'
Stephen Finucane
stephenfinucane at hotmail.com
Mon Nov 24 00:50:07 AEDT 2014
Passing 'mimetype' to 'HttpResponse' is deprecated in 1.6 and
removed in Django 1.7. Among other things, this causes some unit
tests to fail when using Django 1.7. Its replacement - 'content_type'
- is available in Django 1.5+. This can be seen here:
https://docs.djangoproject.com/en/1.5/ref/request-response/#django.http.HttpResponse.__init__
This is therefore a like-for-like replacement.
Signed-off-by: Stephen Finucane <stephenfinucane at hotmail.com>
---
apps/patchwork/views/base.py | 6 +++---
apps/patchwork/views/bundle.py | 2 +-
apps/patchwork/views/patch.py | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/apps/patchwork/views/base.py b/apps/patchwork/views/base.py
index fa7dd99..6d7dd13 100644
--- a/apps/patchwork/views/base.py
+++ b/apps/patchwork/views/base.py
@@ -47,14 +47,14 @@ def pwclientrc(request, project_id):
context['scheme'] = 'https'
else:
context['scheme'] = 'http'
- response = HttpResponse(mimetype = "text/plain")
+ response = HttpResponse(content_type = "text/plain")
response['Content-Disposition'] = 'attachment; filename=.pwclientrc'
response.write(render_to_string('patchwork/pwclientrc', context))
return response
def pwclient(request):
context = PatchworkRequestContext(request)
- response = HttpResponse(mimetype = "text/x-python")
+ response = HttpResponse(content_type = "text/x-python")
response['Content-Disposition'] = 'attachment; filename=pwclient'
response.write(render_to_string('patchwork/pwclient', context))
return response
@@ -87,7 +87,7 @@ def confirm(request, key):
def submitter_complete(request):
search = request.GET.get('q', '')
limit = request.GET.get('l', None)
- response = HttpResponse(mimetype = "text/plain")
+ response = HttpResponse(content_type = "text/plain")
if len(search) <= 3:
return response
diff --git a/apps/patchwork/views/bundle.py b/apps/patchwork/views/bundle.py
index c99e322..3fb47e2 100644
--- a/apps/patchwork/views/bundle.py
+++ b/apps/patchwork/views/bundle.py
@@ -196,7 +196,7 @@ def mbox(request, username, bundlename):
mbox = '\n'.join([patch_to_mbox(p).as_string(True)
for p in bundle.ordered_patches()])
- response = HttpResponse(mimetype='text/plain')
+ response = HttpResponse(content_type='text/plain')
response['Content-Disposition'] = \
'attachment; filename=bundle-%d-%s.mbox' % (bundle.id, bundle.name)
diff --git a/apps/patchwork/views/patch.py b/apps/patchwork/views/patch.py
index 5eedcb5..62ff853 100644
--- a/apps/patchwork/views/patch.py
+++ b/apps/patchwork/views/patch.py
@@ -85,7 +85,7 @@ def patch(request, patch_id):
def content(request, patch_id):
patch = get_object_or_404(Patch, id=patch_id)
- response = HttpResponse(mimetype="text/x-patch")
+ response = HttpResponse(content_type="text/x-patch")
response.write(patch.content)
response['Content-Disposition'] = 'attachment; filename=' + \
patch.filename().replace(';', '').replace('\n', '')
@@ -93,7 +93,7 @@ def content(request, patch_id):
def mbox(request, patch_id):
patch = get_object_or_404(Patch, id=patch_id)
- response = HttpResponse(mimetype="text/plain")
+ response = HttpResponse(content_type="text/plain")
response.write(patch_to_mbox(patch).as_string(True))
response['Content-Disposition'] = 'attachment; filename=' + \
patch.filename().replace(';', '').replace('\n', '')
--
1.9.3
More information about the Patchwork
mailing list