Merge lp:~halkeye/graphite/graphite into lp:~graphite-dev/graphite/main

Proposed by Gavin
Status: Merged
Merged at revision: 755
Proposed branch: lp:~halkeye/graphite/graphite
Merge into: lp:~graphite-dev/graphite/main
Diff against target: 66 lines (+25/-9)
2 files modified
webapp/graphite/browser/views.py (+15/-5)
webapp/graphite/graphlot/views.py (+10/-4)
To merge this branch: bzr merge lp:~halkeye/graphite/graphite
Reviewer Review Type Date Requested Status
Michael Leinartas Approve
Review via email: mp+101461@code.launchpad.net

Description of the change

add callback=? cgi variable to the usergraph tree so dashboards on a different domain can get pre-created graphs.

To post a comment you must log in.
Revision history for this message
Michael Leinartas (mleinartas) wrote :

This looks good, however I saw this merge request too late (sorry) and already merged in basically the same thing in r745 - sorry about that. The difference is that the parameter is called 'jsonp' rather than 'callback', however it works the same way.

r745 didn't have the /graphlot endpoint done as you did so I'm going to make the change to it as you have as well.

Thanks for the contribution

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== 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 @@
150 no_graphs.update(leafNode)150 no_graphs.update(leafNode)
151 nodes.append(no_graphs)151 nodes.append(no_graphs)
152152
153 return json_response(nodes)153 try:
154 jsonp = request.GET['callback']
155 except:
156 jsonp = ""
157 return json_response(nodes, jsonp)
154158
155def userGraphLookup(request):159def userGraphLookup(request):
156 "View for User Graphs navigation"160 "View for User Graphs navigation"
@@ -241,12 +245,18 @@
241 no_graphs.update(leafNode)245 no_graphs.update(leafNode)
242 nodes.append(no_graphs)246 nodes.append(no_graphs)
243247
244 return json_response(nodes)248 try:
245249 jsonp = request.GET['callback']
246250 except:
247def json_response(nodes):251 jsonp = ""
252 return json_response(nodes, jsonp)
253
254
255def json_response(nodes, jsonp):
248 #json = str(nodes) #poor man's json encoder for simple types256 #json = str(nodes) #poor man's json encoder for simple types
249 json_data = json.dumps(nodes)257 json_data = json.dumps(nodes)
258 if (jsonp):
259 json_data = jsonp + '(' + json_data + ');'
250 response = HttpResponse(json_data,mimetype="application/json")260 response = HttpResponse(json_data,mimetype="application/json")
251 response['Pragma'] = 'no-cache'261 response['Pragma'] = 'no-cache'
252 response['Cache-Control'] = 'no-cache'262 response['Cache-Control'] = 'no-cache'
253263
=== 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 @@
246 no_graphs.update(leafNode)246 no_graphs.update(leafNode)
247 nodes.append(no_graphs)247 nodes.append(no_graphs)
248248
249 return json_response(nodes)249 try:
250250 jsonp = request.GET['callback']
251251 except:
252def json_response(nodes):252 jsonp = ""
253 return json_response(nodes, jsonp)
254
255
256def json_response(nodes, jsonp):
253 #json = str(nodes) #poor man's json encoder for simple types257 #json = str(nodes) #poor man's json encoder for simple types
254 json_data = json.dumps(nodes)258 json_data = json.dumps(nodes)
259 if (jsonp):
260 json_data = jsonp + '(' + json_data + ');'
255 response = HttpResponse(json_data,mimetype="application/json")261 response = HttpResponse(json_data,mimetype="application/json")
256 response['Pragma'] = 'no-cache'262 response['Pragma'] = 'no-cache'
257 response['Cache-Control'] = 'no-cache'263 response['Cache-Control'] = 'no-cache'

Subscribers

People subscribed via source and target branches