Created
March 21, 2011 12:44
-
-
Save reedobrien/879395 to your computer and use it in GitHub Desktop.
A jsonp renderer for pyramid
This file contains 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
## from http://pastie.org/1695550 | |
def JsonPRendererFactory(info): | |
"""A special renderer which returns JSONP data. | |
Be careful to only return data that can be dumped to JSON. In particular | |
unicode strings may not work. | |
""" | |
def render(value, system): | |
request=system.get("request") | |
callback=request.params["callback"] | |
request.response_content_type="application/json" | |
return "%s(%s)" % (callback, json.dumps(value)) | |
return render |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment