source: rattail-demo/rattail_demo/web/app.py @ b1875f5

Last change on this file since b1875f5 was b1875f5, checked in by Lance Edgar <ledgar@…>, 12 months ago

Add support for simple postgres restart

  • Property mode set to 100644
File size: 1.3 KB
Line 
1# -*- coding: utf-8; -*-
2"""
3Pyramid web application
4"""
5
6from __future__ import unicode_literals, absolute_import
7
8from tailbone import app
9
10from rattail_demo.web.db import CoreSession, CoreTransSession
11
12
13def main(global_config, **settings):
14    """
15    This function returns a Pyramid WSGI application.
16    """
17    # prefer demo templates over tailbone
18    settings.setdefault('mako.directories', ['rattail_demo.web:templates',
19                                             'tailbone:templates',])
20
21    # for graceful handling of postgres restart
22    settings.setdefault('retry.attempts', 2)
23
24    # make config objects
25    rattail_config = app.make_rattail_config(settings)
26    pyramid_config = app.make_pyramid_config(settings)
27
28    # configure database sessions
29    CoreSession.configure(bind=rattail_config.corepos_engine)
30    CoreTransSession.configure(bind=rattail_config.coretrans_engine)
31
32    # bring in rest of rattail-demo etc.
33    pyramid_config.include('tailbone.static')
34    pyramid_config.include('rattail_demo.web.subscribers')
35    pyramid_config.include('rattail_demo.web.views')
36
37    # for graceful handling of postgres restart
38    pyramid_config.add_tween('tailbone.tweens.sqlerror_tween_factory',
39                             under='pyramid_tm.tm_tween_factory')
40
41    return pyramid_config.make_wsgi_app()
Note: See TracBrowser for help on using the repository browser.