Source

pyramid_sqla / pyramid_sqla / paster_templates / pyramid_sqla / +package+ / __init__.py_tmpl

Full commit
from pyramid.config import Configurator
import pyramid_beaker
import pyramid_sqla

def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    config = Configurator(settings=settings)
    config.include('pyramid_handlers')
    config.include('pyramid_sqla')

    # Initialize database
    pyramid_sqla.add_engine(settings, prefix='sqlalchemy.')

    # Configure Beaker sessions
    session_factory = pyramid_beaker.session_factory_from_settings(settings)
    config.set_session_factory(session_factory)

    # Configure renderers
    config.add_renderer('.html', 'pyramid.mako_templating.renderer_factory')
    config.add_subscriber('{{package}}.subscribers.add_renderer_globals',
                          'pyramid.events.BeforeRender')

    # Set up routes and views
    config.add_handler('home', '/', '{{package}}.handlers:MainHandler',
                       action='index')
    config.add_handler('main', '/{action}', '{{package}}.handlers:MainHandler',
        path_info=r'/(?!favicon\.ico|robots\.txt|w3c)')
    config.add_static_route('{{package}}', 'static', cache_max_age=3600)

    return config.make_wsgi_app()