Issue #235 new

AttributeError: 'WSGIRequest' object has no attribute 'raw_post_data' (Django 1.6 incompatibility)

rvba
created an issue

piston.utils.translate_mime() breaks with Django 1.6 because it uses WSGIRequest().raw_post_data. The field 'raw_post_data' has been deprecated since Django 1.4 and is removed in Django 1.6. It has been renamed 'body' (https://docs.djangoproject.com/en/dev/releases/1.4/#httprequest-raw-post-data-renamed-to-httprequest-body).

from django.core.handlers.wsgi import WSGIRequest
# create object 'request', instance of WSGIRequest.
translate_mime(request)
[...]
    translate_mime(request)
  File "/usr/lib/python2.7/dist-packages/piston/utils.py", line 293, in translate_mime
    request = Mimer(request).translate()
  File "/usr/lib/python2.7/dist-packages/piston/utils.py", line 272, in translate
    self.request.data = loadee(self.request.raw_post_data)
AttributeError: 'WSGIRequest' object has no attribute 'raw_post_data'

The following diff fixes the problem by using 'body' instead 'raw_post_data' in piston/utils.py:

diff -r 7c90898072ce piston/utils.py
--- a/piston/utils.py   Fri Mar 30 18:12:21 2012 -0400
+++ b/piston/utils.py   Mon Dec 02 16:33:25 2013 +0100
@@ -263,7 +263,7 @@

             if loadee:
                 try:
-                    self.request.data = loadee(self.request.raw_post_data)
+                    self.request.data = loadee(self.request.body)

                     # Reset both POST and PUT from request, as its
                     # misleading having their presence around.

Comments (1)

  1. Log in to comment