Ejemplo n.º 1
0
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """

    # Initialize database
    engine = engine_from_config(settings, 'sqlalchemy.')
    initialize_sql(engine)

    authentication_policy = AuthTktAuthenticationPolicy(
        secret='lkjasy222nna!235happy',
        callback=role_finder,
        include_ip=True,
        reissue_time=720,
        http_only=True
    )

    authorization_policy = ACLAuthorizationPolicy()

    session_factory = UnencryptedCookieSessionFactoryConfig('1babble235tomorrow+')

    config = Configurator(
        settings=settings,
        root_factory=root_factory,
        authentication_policy=authentication_policy,
        authorization_policy=authorization_policy,
        session_factory=session_factory
    )

    config.scan()

    config.set_request_factory(RequestWithUser) 

    config.include('cspot.routes')

    config.add_view('cspot.views.auth.forbidden',
                    context='pyramid.httpexceptions.HTTPForbidden',
                    renderer='templates/forbidden.pt')

    return config.make_wsgi_app()
Ejemplo n.º 2
0
def _initTestingDB():
    from sqlalchemy import create_engine
    from cspot.models import initialize_sql
    session = initialize_sql(create_engine('sqlite://'))
    return session