2017-08-13 22:37:38 -05:00
|
|
|
# -*- coding: utf-8; -*-
|
2016-10-06 11:48:32 -05:00
|
|
|
"""
|
|
|
|
Pyramid web application
|
|
|
|
"""
|
|
|
|
|
|
|
|
from tailbone import app
|
2019-07-09 17:34:03 -05:00
|
|
|
from tailbone_corepos.db import CoreOfficeSession, CoreTransSession
|
2018-11-22 11:16:59 -06:00
|
|
|
|
2016-10-06 11:48:32 -05:00
|
|
|
|
|
|
|
def main(global_config, **settings):
|
|
|
|
"""
|
|
|
|
This function returns a Pyramid WSGI application.
|
|
|
|
"""
|
2017-08-13 22:37:38 -05:00
|
|
|
# prefer demo templates over tailbone
|
2016-12-07 20:24:11 -06:00
|
|
|
settings.setdefault('mako.directories', ['rattail_demo.web:templates',
|
2020-03-14 19:50:35 -05:00
|
|
|
'tailbone_corepos:templates',
|
2021-01-20 21:54:52 -06:00
|
|
|
'tailbone_woocommerce:templates',
|
2016-10-06 11:48:32 -05:00
|
|
|
'tailbone:templates',])
|
|
|
|
|
2019-03-03 13:10:08 -06:00
|
|
|
# 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
|
2019-07-09 17:34:03 -05:00
|
|
|
CoreOfficeSession.configure(bind=rattail_config.corepos_engine)
|
2018-11-22 11:16:59 -06:00
|
|
|
CoreTransSession.configure(bind=rattail_config.coretrans_engine)
|
|
|
|
|
2024-06-30 11:55:21 -05:00
|
|
|
# bring in rest of rattail-demo
|
|
|
|
pyramid_config.include('rattail_demo.web.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
|
|
|
|
2019-03-03 13:10:08 -06: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()
|
2022-11-21 22:08:55 -06:00
|
|
|
|
|
|
|
|
|
|
|
def asgi_main():
|
|
|
|
"""
|
|
|
|
This function returns an ASGI application.
|
|
|
|
"""
|
|
|
|
from tailbone.asgi import make_asgi_app
|
|
|
|
|
|
|
|
return make_asgi_app(main)
|