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(name="main_index", pattern="/", view=game_index,
26 renderer='game_index.mako')
29 config.add_route(name="player_weapon_stats",
30 pattern="/game/{game_id:\d+}/stats/{pgstat_id:\d+}",
31 view=player_weapon_stats, renderer='player_weapon_stats.mako')
33 config.add_route(name="player_game_index_default",
34 pattern="/player/{player_id:\d+}/games",
35 view=player_game_index, renderer='player_game_index.mako')
37 config.add_route(name="player_game_index",
38 pattern="/player/{player_id:\d+}/games/page/{page:\d+}",
39 view=player_game_index, renderer='player_game_index.mako')
41 config.add_route(name="player_info", pattern="/player/{id:\d+}", view=player_info,
42 renderer='player_info.mako')
45 config.add_route(name="game_index", pattern="/games", view=game_index,
46 renderer='game_index.mako')
48 config.add_route(name="game_index_paged", pattern="/games/page/{page:\d+}",
49 view=game_index, renderer='game_index.mako')
51 config.add_route(name="game_info", pattern="/game/{id:\d+}", view=game_info,
52 renderer='game_info.mako')
55 config.add_route(name="server_game_index",
56 pattern="/server/{server_id:\d+}/games/page/{page:\d+}",
57 view=server_game_index, renderer='server_game_index.mako')
59 config.add_route(name="server_info", pattern="/server/{id:\d+}", view=server_info,
60 renderer='server_info.mako')
63 config.add_route(name="map_info", pattern="/map/{id:\d+}", view=map_info,
64 renderer='map_info.mako')
66 config.add_route(name="stats_submit", pattern="stats/submit",
67 view=stats_submit, renderer='index.jinja2')
69 return config.make_wsgi_app()