def return_json(func):
"""
A decorator that serializes the output to JSON before returning to the
web client.
"""
def convert_to_json(self, *args, **kwargs):
return_val = func(self, *args, **kwargs)
try:
return render_json(utils.to_json(return_val))
except Exception, e:
import logging
logging.error("problem with serialization: " + str(return_val) + " / " + str(e))
raise e
return update_wrapper(convert_to_json,func)
评论列表
文章目录