|
|
@ -164,14 +164,16 @@ class Api(webserve.MainHandler): |
|
|
|
self.set_header("Content-Type", "application/json") |
|
|
|
try: |
|
|
|
out = json.dumps(dict, indent=self.intent, sort_keys=True) |
|
|
|
callback = self.request.headers.get('callback', None) or self.request.headers.get('jsonp', None) |
|
|
|
if callback != None: |
|
|
|
out = callback + '(' + out + ');' # wrap with JSONP call if requested |
|
|
|
if 'jsonp' in self.request.query_arguments: |
|
|
|
out = self.request.arguments['jsonp'] + '(' + out + ');' # wrap with JSONP call if requested |
|
|
|
|
|
|
|
except Exception, e: # if we fail to generate the output fake an error |
|
|
|
logger.log(u"API :: " + traceback.format_exc(), logger.DEBUG) |
|
|
|
out = '{"result":"' + result_type_map[RESULT_ERROR] + '", "message": "error while composing output: "' + ex( |
|
|
|
e) + '"}' |
|
|
|
return out |
|
|
|
|
|
|
|
tornado_write_hack_dict = {'unwrap_json': out} |
|
|
|
return tornado_write_hack_dict |
|
|
|
|
|
|
|
def _grand_access(self, realKey, args, kwargs): |
|
|
|
""" validate api key and log result """ |
|
|
|