1. Blaise Laflamme
  2. PylonsWikiNG

Source

PylonsWikiNG / src / authorization / tutorial / __init__.py

def main(global_config, **settings):
    """ This function returns a Pylons WSGI application.
    """
    from pylons.configuration import Configurator
    from tutorial.models import initialize_sql
    from repoze.bfg.authentication import AuthTktAuthenticationPolicy
    from repoze.bfg.authorization import ACLAuthorizationPolicy
    from tutorial.security import groupfinder
    from tutorial.views import MyController
    db_string = settings.get('db_string')
    if db_string is None:
        raise ValueError("No 'db_string' value in application "
                         "configuration.")
    initialize_sql(db_string)
    config = Configurator(
        settings=settings,
        authentication_policy=AuthTktAuthenticationPolicy('sosecret', callback=groupfinder),
        authorization_policy=ACLAuthorizationPolicy()
    )
    config.begin()
    config.add_static_view('static', 'tutorial:templates/static')
    config.add_handler('tutorial.views:MyController', pattern='/login',
                       route_name='login', action='login', factory=MyController)
    config.add_handler('tutorial.views:MyController', pattern='/logout',
                       route_name='logout', action='logout', factory=MyController)
    config.add_handler('tutorial.views:MyController', pattern='/',
                       route_name='view_wiki', action='view_wiki', factory=MyController)
    config.add_handler('tutorial.views:MyController', pattern='/{pagename}',
                       route_name='view_page', action='view_page', factory=MyController)
    config.add_handler('tutorial.views:MyController', pattern='/add_page/{pagename}',
                       route_name='add_page', action='add_page', factory=MyController)
    config.add_handler('tutorial.views:MyController', pattern='/{pagename}/edit_page',
                       route_name='edit_page', action='edit_page', factory=MyController)
    config.end()
    return config.make_wsgi_app()