Created
September 29, 2011 23:23
-
-
Save gregorynicholas/1252216 to your computer and use it in GitHub Desktop.
Python method decorator for appengine to ouput json to response.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def jsonresult(func): | |
''' | |
Decorator that sets response headers to output json data. | |
''' | |
def _func(self, *args, **kwargs): | |
self.response.headers['Content-Type'] = "text/plain" | |
logging.debug('--- Outputting JSON Result ---') | |
result = func(self, args, kwargs) | |
self.response.out.write(json.dumps(result)) | |
return _func |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment