After searching the web I think it is possible for web2py to support jsonp,
but there is no concrete example. I am unable to get jsonp to work
correctly and would appreciate any advice.
I have created generic.jsonp containing the following:
{{
###
# response._vars contains the dictionary returned by the controller action
###
try:
from gluon.serializers import json
result = "%s(%s)" % (request.vars['callback'], json(response._vars))
response.write(result, escape=False)
response.headers['Content-Type'] = 'application/jsonp'
except (TypeError, ValueError):
raise HTTP(405, 'JSON serialization error')
except ImportError:
raise HTTP(405, 'JSON not available')
except:
raise HTTP(405, 'JSON error')
}}
I have a controller containing the following:
def test():
meetings=db(db.meeting).select()
return meetings
I try and invoke using www.siteurl/app/api/test.jsonp?callback=?
I am not jsonp is supported by the service decorators either?
What would be most useful is a example that I know works form which I can
reference and experiment.