rattail-demo/rattail_demo/web/app.py

42 lines
1.3 KiB
Python
Raw Normal View History

# -*- coding: utf-8; -*-
2016-10-06 11:48:32 -05:00
"""
Pyramid web application
"""
from __future__ import unicode_literals, absolute_import
from tailbone import app
2018-11-22 11:16:59 -06:00
from rattail_demo.web.db import CoreSession, CoreTransSession
2016-10-06 11:48:32 -05:00
def main(global_config, **settings):
"""
This function returns a Pyramid WSGI application.
"""
# prefer demo templates over tailbone
2016-12-07 20:24:11 -06:00
settings.setdefault('mako.directories', ['rattail_demo.web:templates',
2016-10-06 11:48:32 -05:00
'tailbone:templates',])
# for graceful handling of postgres restart
settings.setdefault('retry.attempts', 2)
2016-10-06 11:48:32 -05:00
# make config objects
rattail_config = app.make_rattail_config(settings)
pyramid_config = app.make_pyramid_config(settings)
2018-11-22 11:16:59 -06:00
# configure database sessions
CoreSession.configure(bind=rattail_config.corepos_engine)
CoreTransSession.configure(bind=rattail_config.coretrans_engine)
2016-12-07 20:24:11 -06:00
# bring in rest of rattail-demo etc.
2016-10-06 11:48:32 -05:00
pyramid_config.include('tailbone.static')
2016-12-10 15:40:21 -06:00
pyramid_config.include('rattail_demo.web.subscribers')
2016-12-07 20:24:11 -06:00
pyramid_config.include('rattail_demo.web.views')
2016-10-06 11:48:32 -05:00
# for graceful handling of postgres restart
pyramid_config.add_tween('tailbone.tweens.sqlerror_tween_factory',
under='pyramid_tm.tm_tween_factory')
2016-10-06 11:48:32 -05:00
return pyramid_config.make_wsgi_app()