I have some existing python code that uses django-piston which returns a dictionary as an answer. For instance:
from piston.handler import BaseHandler
class FooHandler(BaseHandler):
allowed_methods = ('GET',)
@classmethod
def create(self, request):
return { 'foo': 'bar' }
This code works fine and is serialized in JSON with the appropriate set of HTTP headers (I assume it works with some kind of piston magic involving emitters, for bonus points feel free to clarify how this works, as I'm still recognizing the django piston )
I need to be able to modify the answer in arbitrary ways, for example. installation headers, status codes, etc., without using any pre-baked solution designed for a specific purpose. Is there a convenient way to access the response object in the context of this code and manipulate it, or is the response object not yet created? To access the response object, I will have to manually create it (a la vanilla django), serialize the dictionary and set the corresponding headers manually and, thus, play some of the useful magic of the django piston
source
share