graphite-dev team mailing list archive
-
graphite-dev team
-
Mailing list archive
-
Message #02416
[Merge] lp:~halkeye/graphite/graphite into lp:graphite
Gavin has proposed merging lp:~halkeye/graphite/graphite into lp:graphite.
Requested reviews:
graphite-dev (graphite-dev)
For more details, see:
https://code.launchpad.net/~halkeye/graphite/graphite/+merge/101461
add callback=? cgi variable to the usergraph tree so dashboards on a different domain can get pre-created graphs.
--
https://code.launchpad.net/~halkeye/graphite/graphite/+merge/101461
Your team graphite-dev is requested to review the proposed merge of lp:~halkeye/graphite/graphite into lp:graphite.
=== modified file 'webapp/graphite/browser/views.py'
--- webapp/graphite/browser/views.py 2011-12-05 06:12:33 +0000
+++ webapp/graphite/browser/views.py 2012-04-11 00:05:21 +0000
@@ -150,7 +150,11 @@
no_graphs.update(leafNode)
nodes.append(no_graphs)
- return json_response(nodes)
+ try:
+ jsonp = request.GET['callback']
+ except:
+ jsonp = ""
+ return json_response(nodes, jsonp)
def userGraphLookup(request):
"View for User Graphs navigation"
@@ -241,12 +245,18 @@
no_graphs.update(leafNode)
nodes.append(no_graphs)
- return json_response(nodes)
-
-
-def json_response(nodes):
+ try:
+ jsonp = request.GET['callback']
+ except:
+ jsonp = ""
+ return json_response(nodes, jsonp)
+
+
+def json_response(nodes, jsonp):
#json = str(nodes) #poor man's json encoder for simple types
json_data = json.dumps(nodes)
+ if (jsonp):
+ json_data = jsonp + '(' + json_data + ');'
response = HttpResponse(json_data,mimetype="application/json")
response['Pragma'] = 'no-cache'
response['Cache-Control'] = 'no-cache'
=== modified file 'webapp/graphite/graphlot/views.py'
--- webapp/graphite/graphlot/views.py 2011-12-05 06:43:23 +0000
+++ webapp/graphite/graphlot/views.py 2012-04-11 00:05:21 +0000
@@ -246,12 +246,18 @@
no_graphs.update(leafNode)
nodes.append(no_graphs)
- return json_response(nodes)
-
-
-def json_response(nodes):
+ try:
+ jsonp = request.GET['callback']
+ except:
+ jsonp = ""
+ return json_response(nodes, jsonp)
+
+
+def json_response(nodes, jsonp):
#json = str(nodes) #poor man's json encoder for simple types
json_data = json.dumps(nodes)
+ if (jsonp):
+ json_data = jsonp + '(' + json_data + ');'
response = HttpResponse(json_data,mimetype="application/json")
response['Pragma'] = 'no-cache'
response['Cache-Control'] = 'no-cache'