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
1=== modified file 'webapp/graphite/browser/views.py'
2--- webapp/graphite/browser/views.py 2011-12-05 06:12:33 +0000
3+++ webapp/graphite/browser/views.py 2012-04-11 00:05:21 +0000
4@@ -150,7 +150,11 @@
5 no_graphs.update(leafNode)
6 nodes.append(no_graphs)
7
8- return json_response(nodes)
9+ try:
10+ jsonp = request.GET['callback']
11+ except:
12+ jsonp = ""
13+ return json_response(nodes, jsonp)
14
15 def userGraphLookup(request):
16 "View for User Graphs navigation"
17@@ -241,12 +245,18 @@
18 no_graphs.update(leafNode)
19 nodes.append(no_graphs)
20
21- return json_response(nodes)
22-
23-
24-def json_response(nodes):
25+ try:
26+ jsonp = request.GET['callback']
27+ except:
28+ jsonp = ""
29+ return json_response(nodes, jsonp)
30+
31+
32+def json_response(nodes, jsonp):
33 #json = str(nodes) #poor man's json encoder for simple types
34 json_data = json.dumps(nodes)
35+ if (jsonp):
36+ json_data = jsonp + '(' + json_data + ');'
37 response = HttpResponse(json_data,mimetype="application/json")
38 response['Pragma'] = 'no-cache'
39 response['Cache-Control'] = 'no-cache'
40
41=== modified file 'webapp/graphite/graphlot/views.py'
42--- webapp/graphite/graphlot/views.py 2011-12-05 06:43:23 +0000
43+++ webapp/graphite/graphlot/views.py 2012-04-11 00:05:21 +0000
44@@ -246,12 +246,18 @@
45 no_graphs.update(leafNode)
46 nodes.append(no_graphs)
47
48- return json_response(nodes)
49-
50-
51-def json_response(nodes):
52+ try:
53+ jsonp = request.GET['callback']
54+ except:
55+ jsonp = ""
56+ return json_response(nodes, jsonp)
57+
58+
59+def json_response(nodes, jsonp):
60 #json = str(nodes) #poor man's json encoder for simple types
61 json_data = json.dumps(nodes)
62+ if (jsonp):
63+ json_data = jsonp + '(' + json_data + ');'
64 response = HttpResponse(json_data,mimetype="application/json")
65 response['Pragma'] = 'no-cache'
66 response['Cache-Control'] = 'no-cache'

Subscribers

People subscribed via source and target branches