3 from pyramid.config import Configurator
4 from sqlalchemy import engine_from_config
5 from xonstat.models import initialize_db
6 from xonstat.views import *
8 def main(global_config, **settings):
9 """ This function returns a Pyramid WSGI application.
11 # setup the database engine
12 engine = engine_from_config(settings, 'sqlalchemy.')
13 sqlahelper.add_engine(engine)
15 # initialize database structures
18 config = Configurator(settings=settings)
20 config.add_renderer('.jinja2', pyramid_jinja2.renderer_factory)
22 config.add_static_view('static', 'xonstat:static')
25 config.add_route("main_index", "/")
26 config.add_view(main_index, route_name="main_index",
27 renderer="main_index.mako")
30 config.add_route("player_game_index_paged",
31 "/player/{player_id:\d+}/games/page/{page:\d+}")
32 config.add_view(player_game_index, route_name="player_game_index_paged",
33 renderer="player_game_index.mako")
35 config.add_route("player_game_index",
36 "/player/{player_id:\d+}/games")
37 config.add_view(player_game_index, route_name="player_game_index",
38 renderer="player_game_index.mako")
40 config.add_route("player_index_paged", "/players/page/{page:\d+}")
41 config.add_view(player_index, route_name="player_index_paged",
42 renderer="player_index.mako")
44 config.add_route("player_index", "/players")
45 config.add_view(player_index, route_name="player_index",
46 renderer="player_index.mako")
48 config.add_route("player_info", "/player/{id:\d+}")
49 config.add_view(player_info, route_name="player_info",
50 renderer="player_info.mako")
53 config.add_route("game_index", "/games")
54 config.add_view(game_index, route_name="game_index",
55 renderer="game_index.mako")
57 config.add_route("game_index_paged", "/games/page/{page:\d+}")
58 config.add_view(game_index, route_name="game_index_paged",
59 renderer="game_index.mako")
61 config.add_route("game_info", "/game/{id:\d+}")
62 config.add_view(game_info, route_name="game_info",
63 renderer="game_info.mako")
65 config.add_route("rank_index", "/ranks/{game_type_cd:ctf|dm|tdm|duel}")
66 config.add_view(rank_index, route_name="rank_index",
67 renderer="rank_index.mako")
69 config.add_route("rank_index_paged", "/ranks/{game_type_cd:ctf|dm|tdm|duel}/page/{page:\d+}")
70 config.add_view(rank_index, route_name="rank_index_paged",
71 renderer="rank_index.mako")
74 config.add_route("server_index_paged", "/servers/page/{page:\d+}")
75 config.add_view(server_index, route_name="server_index_paged",
76 renderer="server_index.mako")
78 config.add_route("server_index", "/servers")
79 config.add_view(server_index, route_name="server_index",
80 renderer="server_index.mako")
82 config.add_route("server_game_index",
83 "/server/{server_id:\d+}/games/page/{page:\d+}")
84 config.add_view(server_game_index, route_name="server_game_index",
85 renderer="server_game_index.mako")
87 config.add_route("server_info", "/server/{id:\d+}")
88 config.add_view(server_info, route_name="server_info",
89 renderer="server_info.mako")
92 config.add_route("map_index_paged", "/maps/page/{page:\d+}")
93 config.add_view(map_index, route_name="map_index_paged",
94 renderer="map_index.mako")
96 config.add_route("map_index", "/maps")
97 config.add_view(map_index, route_name="map_index",
98 renderer="map_index.mako")
100 config.add_route("map_info", "/map/{id:\d+}")
101 config.add_view(map_info, route_name="map_info",
102 renderer="map_info.mako")
104 config.add_route("stats_submit", "stats/submit")
105 config.add_view(stats_submit, route_name="stats_submit",
106 renderer="index.jinja2")
109 config.add_route("search", "search")
110 config.add_view(search, route_name="search",
111 renderer="search.mako")
113 config.add_route("search_paged", "search/page/{page:\d+}")
114 config.add_view(search, route_name="search_paged",
115 renderer="search.mako")
118 return config.make_wsgi_app()