summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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'