Source

tw2.core-docs-pyramid / myapp / myapp / __init__.py

Full commit
from pyramid.config import Configurator
from sqlalchemy import engine_from_config

from myapp.models import appmaker

def main(global_config, **settings):
    """ This function returns a WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    get_root = appmaker(engine)
    config = Configurator(settings=settings, root_factory=get_root)
    config.add_static_view('static', 'myapp:static')
    config.add_view('myapp.views.view_root', 
                    context='myapp.models.MyApp', 
                    renderer="templates/root.pt")
    config.add_view('myapp.views.view_model',
                    context='myapp.models.MyModel',
                    renderer="templates/model.pt")

    config.add_view('myapp.views.view_widget',
                    context='myapp.widgets.MovieForm',
                    renderer="templates/widget.pt")
    config.add_view('myapp.views.view_widget',
                    context='myapp.widgets.MovieList',
                    renderer="templates/widget.pt")
    config.add_view('myapp.views.view_grid_widget',
                    context='myapp.widgets.GridWidget',
                    renderer="templates/widget.pt")

    return config.make_wsgi_app()