generic.jsonp 752 B

1234567891011121314151617181920212223
  1. {{
  2. ###
  3. # response._vars contains the dictionary returned by the controller action
  4. ###
  5. # security check! This file is an example for a jsonp view.
  6. # it is not safe to use as a generic.jsonp because of security implications.
  7. if response.view == 'generic.jsonp':
  8. raise HTTP(501,'generic.jsonp diasbled for security reasons')
  9. try:
  10. from gluon.serializers import json
  11. result = "%s(%s)" % (request.vars['callback'], json(response._vars))
  12. response.write(result, escape=False)
  13. response.headers['Content-Type'] = 'application/jsonp'
  14. except (TypeError, ValueError):
  15. raise HTTP(405, 'JSON serialization error')
  16. except ImportError:
  17. raise HTTP(405, 'JSON not available')
  18. except:
  19. raise HTTP(405, 'JSON error')
  20. }}