summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLeif Johansson <leifj@sunet.se>2011-10-11 23:20:32 +0200
committerLeif Johansson <leifj@sunet.se>2011-10-11 23:20:32 +0200
commit8a731e46293ea760b856462b9e82968451e8f36d (patch)
treebe050fde07a77d1aeada94cc7fb1d823f4af3636 /src
parentf73c20cbe36bfdd2b788648967da30fa9a3f64f1 (diff)
support jsonp
Diffstat (limited to 'src')
-rw-r--r--src/meetingtools/apps/room/views.py2
-rw-r--r--src/meetingtools/multiresponse.py11
2 files changed, 10 insertions, 3 deletions
diff --git a/src/meetingtools/apps/room/views.py b/src/meetingtools/apps/room/views.py
index 0cc6cbe..59acdba 100644
--- a/src/meetingtools/apps/room/views.py
+++ b/src/meetingtools/apps/room/views.py
@@ -412,7 +412,7 @@ def list_by_tag(request,tn):
title = 'Rooms tagged with %s' % " and ".join(tags)
return respond_to(request,
{'text/html':'apps/room/list.html',
- 'application/json': json_response([_room2dict(room) for room in rooms])},
+ 'application/json': json_response([_room2dict(room) for room in rooms],request)},
{'title':title,
'description':title ,
'edit':False,
diff --git a/src/meetingtools/multiresponse.py b/src/meetingtools/multiresponse.py
index 5c58774..077f446 100644
--- a/src/meetingtools/multiresponse.py
+++ b/src/meetingtools/multiresponse.py
@@ -34,8 +34,15 @@ def make_response_dict(request,d={}):
return d
-def json_response(data):
- r = HttpResponse(simplejson.dumps(data),content_type='application/json')
+def json_response(data,request=None):
+ response_data = None
+ if request and request.GET.has_key('callback'):
+ callback = request.GET['callback']
+ json = simplejson.dumps(data)
+ response_data = "%s(%s)" % (callback, json)
+ else:
+ response_data = simplejson.dumps(data)
+ r = HttpResponse(response_data,content_type='application/json')
r['Cache-Control'] = 'no-cache, must-revalidate'
r['Pragma'] = 'no-cache'