Commits

Jesper Nøhr  committed 1a329d4

passing http responses straight through, not double escaping

  • Participants
  • Parent commits 3f26163

Comments (0)

Files changed (1)

File piston/resource.py

         try:
             result = meth(request, *args, **kwargs)
         except FormValidationError, e:
-            # TODO: Use rc.BAD_REQUEST here
-            return HttpResponse("Bad Request: %s" % e.form.errors, status=400)
+            resp = rc.BAD_REQUEST
+            resp.write(e.form.errors)
+            
+            return rsep
         except TypeError, e:
             result = rc.BAD_REQUEST
             hm = HandlerMethod(meth)
-            sig = hm.get_signature()
+            sig = hm.signature
 
             msg = 'Method signature does not match.\n\n'
             
                 
             result.content = format_error(msg)
         except HttpStatusCode, e:
-            #result = e ## why is this being passed on and not just dealt with now?
             return e.response
         except Exception, e:
             """
             if self.stream: stream = srl.stream_render(request)
             else: stream = srl.render(request)
 
-            resp = HttpResponse(stream, mimetype=ct)
+            if not isinstance(stream, HttpResponse):
+                resp = HttpResponse(stream, mimetype=ct)
+            else:
+                resp = stream
 
             resp.streaming = self.stream