]> de.git.xonotic.org Git - xonotic/xonstat.git/blob - xonstat/__init__.py
Fix integrity errors when creating player_game_stat records.
[xonotic/xonstat.git] / xonstat / __init__.py
1 import pyramid_jinja2
2 import sqlahelper
3 from pyramid.config import Configurator
4 from sqlalchemy import engine_from_config
5
6 def main(global_config, **settings):
7     """ This function returns a Pyramid WSGI application.
8     """
9     # setup the database engine
10     engine = engine_from_config(settings, 'sqlalchemy.')
11     sqlahelper.add_engine(engine)
12
13     # create the database structures
14     # note: have to import here else we'll get` 
15     # "no engine 'default' was configured
16     from xonstat.models import initialize_sql
17     initialize_sql(engine)
18
19     # import the views
20     # note: have to import here else we'll get` 
21     # "no engine 'default' was configured
22     from xonstat.views import * 
23
24     config = Configurator(settings=settings)
25
26     config.add_renderer('.jinja2', pyramid_jinja2.renderer_factory)
27
28     config.add_static_view('static', 'xonstat:static')
29
30     config.add_route(name="main_index", pattern="/", view=main_index, 
31             renderer='index.jinja2') 
32     config.add_route(name="stats_submit", pattern="stats/submit", view=stats_submit, 
33             renderer='index.jinja2') 
34     return config.make_wsgi_app()
35
36