source: tmcsimulator/branches/LCSv2/views/generic.jsonp @ 619

Revision 619, 753 bytes checked in by jdalbey, 6 years ago (diff)

Add branch LCSv2

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