1. Luke Plant
  2. django-piston


Alexander Ljungberg  committed ffd444d Merge


  • Participants
  • Parent commits ca281ce, 87c9a20
  • Branches default

Comments (0)

Files changed (1)

File piston/utils.py

View file
     in mod_python. This should fix it.
     if request.method == "PUT":
+        # Bug fix: if _load_post_and_files has already been called, for
+        # example by middleware accessing request.POST, the below code to
+        # pretend the request is a POST instead of a PUT will be too late
+        # to make a difference. Also calling _load_post_and_files will result 
+        # in the following exception:
+        #   AttributeError: You cannot set the upload handlers after the upload has been processed.
+        # The fix is to check for the presence of the _post field which is set 
+        # the first time _load_post_and_files is called (both by wsgi.py and 
+        # modpython.py). If it's set, the request has to be 'reset' to redo
+        # the query value parsing in POST mode.
+        if hasattr(request, '_post'):
+            del request._post
+            del request._files
             request.method = "POST"