2 from pyramid.config import Configurator
3 from sqlalchemy import engine_from_config
4 from xonstat.models import initialize_db
5 from xonstat.views import *
7 def main(global_config, **settings):
8 """ This function returns a Pyramid WSGI application.
10 # setup the database engine
11 engine = engine_from_config(settings, 'sqlalchemy.')
12 sqlahelper.add_engine(engine)
14 # initialize database structures
17 config = Configurator(settings=settings)
19 config.add_static_view('static', 'xonstat:static')
22 config.add_route("main_index", "/")
23 config.add_view(main_index, route_name="main_index",
24 renderer="main_index.mako")
26 # MAIN SUBMISSION ROUTE
27 config.add_route("stats_submit", "stats/submit")
28 config.add_view(stats_submit, route_name="stats_submit")
31 config.add_route("player_game_index",
32 "/player/{player_id:\d+}/games")
33 config.add_view(player_game_index, route_name="player_game_index",
34 renderer="player_game_index.mako")
36 config.add_route("player_index", "/players")
37 config.add_view(player_index, route_name="player_index",
38 renderer="player_index.mako")
40 config.add_route("player_info", "/player/{id:\d+}")
41 config.add_view(player_info, route_name="player_info",
42 renderer="player_info.mako")
44 config.add_route("player_accuracy", "/player/{id:\d+}/accuracy")
45 config.add_view(player_accuracy, route_name="player_accuracy",
49 config.add_route("game_index", "/games")
50 config.add_view(game_index, route_name="game_index",
51 renderer="game_index.mako")
53 config.add_route("game_info", "/game/{id:\d+}")
54 config.add_view(game_info, route_name="game_info",
55 renderer="game_info.mako")
57 config.add_route("rank_index", "/ranks/{game_type_cd:ctf|dm|tdm|duel}")
58 config.add_view(rank_index, route_name="rank_index",
59 renderer="rank_index.mako")
62 config.add_route("server_index", "/servers")
63 config.add_view(server_index, route_name="server_index",
64 renderer="server_index.mako")
66 config.add_route("server_game_index",
67 "/server/{server_id:\d+}/games/page/{page:\d+}")
68 config.add_view(server_game_index, route_name="server_game_index",
69 renderer="server_game_index.mako")
71 config.add_route("server_info", "/server/{id:\d+}")
72 config.add_view(server_info, route_name="server_info",
73 renderer="server_info.mako")
76 config.add_route("map_index_json", "/maps.json")
77 config.add_view(map_index_json, route_name="map_index_json",
80 config.add_route("map_index", "/maps")
81 config.add_view(map_index, route_name="map_index",
82 renderer="map_index.mako")
84 config.add_route("map_info", "/map/{id:\d+}")
85 config.add_view(map_info, route_name="map_info",
86 renderer="map_info.mako")
89 config.add_route("search", "search")
90 config.add_view(search, route_name="search",
91 renderer="search.mako")
93 return config.make_wsgi_app()