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_paged",
32 "/player/{player_id:\d+}/games/page/{page:\d+}")
33 config.add_view(player_game_index, route_name="player_game_index_paged",
34 renderer="player_game_index.mako")
36 config.add_route("player_game_index",
37 "/player/{player_id:\d+}/games")
38 config.add_view(player_game_index, route_name="player_game_index",
39 renderer="player_game_index.mako")
41 config.add_route("player_index_paged", "/players/page/{page:\d+}")
42 config.add_view(player_index, route_name="player_index_paged",
43 renderer="player_index.mako")
45 config.add_route("player_index", "/players")
46 config.add_view(player_index, route_name="player_index",
47 renderer="player_index.mako")
49 config.add_route("player_info", "/player/{id:\d+}")
50 config.add_view(player_info, route_name="player_info",
51 renderer="player_info.mako")
53 config.add_route("player_accuracy", "/player/{id:\d+}/accuracy")
54 config.add_view(player_accuracy, route_name="player_accuracy",
58 config.add_route("game_index", "/games")
59 config.add_view(game_index, route_name="game_index",
60 renderer="game_index.mako")
62 config.add_route("game_index_paged", "/games/page/{page:\d+}")
63 config.add_view(game_index, route_name="game_index_paged",
64 renderer="game_index.mako")
66 config.add_route("game_info", "/game/{id:\d+}")
67 config.add_view(game_info, route_name="game_info",
68 renderer="game_info.mako")
70 config.add_route("rank_index", "/ranks/{game_type_cd:ctf|dm|tdm|duel}")
71 config.add_view(rank_index, route_name="rank_index",
72 renderer="rank_index.mako")
74 config.add_route("rank_index_paged", "/ranks/{game_type_cd:ctf|dm|tdm|duel}/page/{page:\d+}")
75 config.add_view(rank_index, route_name="rank_index_paged",
76 renderer="rank_index.mako")
79 config.add_route("server_index_paged", "/servers/page/{page:\d+}")
80 config.add_view(server_index, route_name="server_index_paged",
81 renderer="server_index.mako")
83 config.add_route("server_index", "/servers")
84 config.add_view(server_index, route_name="server_index",
85 renderer="server_index.mako")
87 config.add_route("server_game_index",
88 "/server/{server_id:\d+}/games/page/{page:\d+}")
89 config.add_view(server_game_index, route_name="server_game_index",
90 renderer="server_game_index.mako")
92 config.add_route("server_info", "/server/{id:\d+}")
93 config.add_view(server_info, route_name="server_info",
94 renderer="server_info.mako")
97 config.add_route("map_index_paged", "/maps/page/{page:\d+}")
98 config.add_view(map_index, route_name="map_index_paged",
99 renderer="map_index.mako")
101 config.add_route("map_index", "/maps")
102 config.add_view(map_index, route_name="map_index",
103 renderer="map_index.mako")
105 config.add_route("map_info", "/map/{id:\d+}")
106 config.add_view(map_info, route_name="map_info",
107 renderer="map_info.mako")
110 config.add_route("search", "search")
111 config.add_view(search, route_name="search",
112 renderer="search.mako")
114 config.add_route("search_paged", "search/page/{page:\d+}")
115 config.add_view(search, route_name="search_paged",
116 renderer="search.mako")
119 return config.make_wsgi_app()