I am wondering how best to handle JSONp objects using tornado in python,
is it best to do this:
class BaseRequest(tornado.web.RequestHandler):
def prepare(self):
self.result = {"success": True};
def finish(self, chunk=None):
self.write(self.result);
tornado.web.RequestHandler.finish(self, chunk);
This seems like a bad idea because you’d think you could do it in on_finish(), right?
So, should I do it like above or should I write() in each of my handlers?
You should override the default
writemethod and do something like this (untested):where
stuffis a dictionary andcallbackis the jsonp callback name.