]> git.xonotic.org Git - xonotic/xonstat.git/commitdiff
Use jsonp renderer for remote requests (or this API would be pretty moot)
authornyov <nyov@nexnode.net>
Tue, 5 Jun 2012 02:38:06 +0000 (04:38 +0200)
committernyov <nyov@nexnode.net>
Tue, 5 Jun 2012 02:38:06 +0000 (04:38 +0200)
JSONP allows cross-domain requests by wrapping output
in a function call if requested.
Requires pyramid>=1.1

XonStat.egg-info/requires.txt
xonstat/__init__.py

index 2950c076dd8a670e8470f2433144ab9f37ce02b4..fdef49787cd86fbe8c62a989ff1d795eab1552b6 100644 (file)
@@ -1,4 +1,4 @@
-pyramid
+pyramid>=1.1
 SQLAlchemy
 transaction
 repoze.tm2>=1.0b1
index 2e45a0853d4d47e1815a28f8c1e3a6a37ed44476..9b66b81111bc72d3ac4a59fbf589282ff8b906a9 100644 (file)
@@ -1,5 +1,6 @@
 import sqlahelper
 from pyramid.config import Configurator
+from pyramid.renderers import JSONP
 from sqlalchemy import engine_from_config
 from xonstat.models import initialize_db
 from xonstat.views import *
@@ -18,6 +19,8 @@ def main(global_config, **settings):
 
     config.add_static_view('static', 'xonstat:static')
 
+    config.add_renderer('jsonp', JSONP(param_name='callback'))
+
     # ROOT ROUTE
     config.add_route("main_index", "/")
     config.add_view(main_index, route_name="main_index", renderer="main_index.mako")
@@ -38,8 +41,8 @@ def main(global_config, **settings):
 
     config.add_route("player_accuracy",      "/player/{id:\d+}/accuracy")
     config.add_route("player_accuracy_json", "/player/{id:\d+}/accuracy.json")
-    config.add_view(player_accuracy_json, route_name="player_accuracy",      renderer="json")
-    config.add_view(player_accuracy_json, route_name="player_accuracy_json", renderer="json")
+    config.add_view(player_accuracy_json, route_name="player_accuracy",      renderer="jsonp")
+    config.add_view(player_accuracy_json, route_name="player_accuracy_json", renderer="jsonp")
 
     # GAME ROUTES
     config.add_route("game_index", "/games")
@@ -65,7 +68,7 @@ def main(global_config, **settings):
     config.add_route("map_index",      "/maps")
     config.add_route("map_index_json", "/maps.json")
     config.add_view(map_index,      route_name="map_index",      renderer="map_index.mako")
-    config.add_view(map_index_json, route_name="map_index_json", renderer="json")
+    config.add_view(map_index_json, route_name="map_index_json", renderer="jsonp")
 
     config.add_route("map_info", "/map/{id:\d+}")
     config.add_view(map_info, route_name="map_info", renderer="map_info.mako")