]> git.rm.cloudns.org Git - xonotic/xonstat.git/commitdiff
Assume hashkeys are double quoted.
authorAnt Zucaro <azucaro@gmail.com>
Fri, 13 Dec 2013 01:43:15 +0000 (20:43 -0500)
committerAnt Zucaro <azucaro@gmail.com>
Fri, 13 Dec 2013 01:43:15 +0000 (20:43 -0500)
xonstat/__init__.py
xonstat/views/player.py

index b2314b3a1f64415a148dac76b43fc4fb9fdc6db4..c38d31c0790541339a0388162fc0c94f3ca50c76 100644 (file)
@@ -48,7 +48,7 @@ def main(global_config, **settings):
     config.add_route("player_info",      "/player/{id:\d+}")
     config.add_view(player_info,      route_name="player_info",      renderer="player_info.mako")
 
-    config.add_route("player_hashkey_info_json", "/player/{hashkey:.{44}}.json")
+    config.add_route("player_hashkey_info_json", "/player/me.json")
     config.add_view(player_hashkey_info_json, route_name="player_hashkey_info_json", renderer="jsonp")
 
     config.add_route("player_hashkey_info_text", "/player/me")
@@ -60,7 +60,8 @@ def main(global_config, **settings):
     config.add_route("player_elo_info_text", "/player/{hashkey}/elo.txt")
     config.add_view(player_elo_info_text, route_name="player_elo_info_text", renderer="player_elo_info_text.mako")
 
-    config.add_route("player_elo_info_json", "/player/{hashkey}/elo.json") ## FIXME - doesn't seem to work?
+    # FIXME - needs an additional method to convert to JSON
+    config.add_route("player_elo_info_json", "/player/{hashkey}/elo.json")
     config.add_view(player_elo_info_json, route_name="player_elo_info_json", renderer="jsonp")
 
     config.add_route("player_accuracy",      "/player/{id:\d+}/accuracy")
index 41217e5e7d657bde0beb94dbd23d4da5e412c771..19ec08165039cd55790f70f51dc757b8284ceb09 100644 (file)
@@ -10,6 +10,7 @@ from xonstat.models import *
 from xonstat.util import page_url, to_json, pretty_date, datetime_seconds
 from xonstat.util import is_cake_day, verify_request
 from xonstat.views.helpers import RecentGame, recent_games_q
+from urllib import unquote
 
 log = logging.getLogger(__name__)
 
@@ -788,7 +789,13 @@ def player_damage_json(request):
 
 
 def player_hashkey_info_data(request):
-    (idfp, status) = verify_request(request)
+    # hashkey = request.matchdict['hashkey']
+
+    # the incoming hashkey is double quoted, and WSGI unquotes once...
+    # hashkey = unquote(hashkey)
+
+    # if using request verification to obtain the hashkey
+    (hashkey, status) = verify_request(request)
 
     # if config is to *not* verify requests and we get nothing back, this
     # query will return nothing and we'll 404.
@@ -796,7 +803,7 @@ def player_hashkey_info_data(request):
         player = DBSession.query(Player).\
                 filter(Player.player_id == Hashkey.player_id).\
                 filter(Player.active_ind == True).\
-                filter(Hashkey.hashkey == idfp).one()
+                filter(Hashkey.hashkey == hashkey).one()
 
         games_played      = get_games_played(player.player_id)
         overall_stats     = get_overall_stats(player.player_id)
@@ -913,7 +920,10 @@ def player_elo_info_data(request):
     Provides elo information on a specific player. Raw data is returned.
     """
     hashkey = request.matchdict['hashkey']
-    print "player_elo_info_data [hashkey={0}]".format(hashkey)
+
+    # the incoming hashkey is double quoted, and WSGI unquotes once...
+    hashkey = unquote(hashkey)
+
     try:
         player = DBSession.query(Player).\
                 filter(Player.player_id == Hashkey.player_id).\