Esempio n. 1
0
def main(global_config, **settings):
    # paster app config callback
    engine = engine_from_config(settings, "sqlalchemy.")
    initialize_sql(engine)
    config = Configurator(
        settings=settings, root_factory="shootout.models.Range", locale_negotiator=default_locale_negotiator
    )
    session_factory = session_factory_from_settings(settings)
    config.set_session_factory(session_factory)
    config.add_renderer(".jinja2", renderer_factory)
    config.include(pyramid_zcml)
    config.load_zcml("shootout:configure.zcml")
    return config.make_wsgi_app()
Esempio n. 2
0
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    initialize_sql(engine)

    session_factory = UnencryptedCookieSessionFactoryConfig('secret')

    authn_policy = AuthTktAuthenticationPolicy('s0secret')
    authz_policy = ACLAuthorizationPolicy()

    config = Configurator(
        settings=settings,
        root_factory='shootout.models.RootFactory',
        authentication_policy=authn_policy,
        authorization_policy=authz_policy,
        session_factory=session_factory
    )

    config.add_subscriber('shootout.subscribers.add_base_template',
                          'pyramid.events.BeforeRender')
    config.add_subscriber('shootout.subscribers.csrf_validation',
                          'pyramid.events.NewRequest')

    config.add_static_view('static', 'shootout:static')

    config.add_route('idea', '/ideas/{idea_id}')
    config.add_route('user', '/users/{username}')
    config.add_route('tag', '/tags/{tag_name}')
    config.add_route('idea_add', '/idea_add')
    config.add_route('idea_vote', '/idea_vote')
    config.add_route('register', '/register')
    config.add_route('login', '/login')
    config.add_route('logout', '/logout')
    config.add_route('about', '/about')
    config.add_route('main', '/')

    config.scan()

    return config.make_wsgi_app()
Esempio n. 3
0
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    initialize_sql(engine)

    session_factory = UnencryptedCookieSessionFactoryConfig('secret')

    authn_policy = AuthTktAuthenticationPolicy('s0secret')
    authz_policy = ACLAuthorizationPolicy()

    config = Configurator(settings=settings,
                          root_factory='shootout.models.RootFactory',
                          authentication_policy=authn_policy,
                          authorization_policy=authz_policy,
                          session_factory=session_factory)

    config.add_subscriber('shootout.subscribers.add_base_template',
                          'pyramid.events.BeforeRender')
    config.add_subscriber('shootout.subscribers.csrf_validation',
                          'pyramid.events.NewRequest')

    config.add_static_view('static', 'shootout:static')

    config.add_route('idea', '/ideas/{idea_id}')
    config.add_route('user', '/users/{username}')
    config.add_route('tag', '/tags/{tag_name}')
    config.add_route('idea_add', '/idea_add')
    config.add_route('idea_vote', '/idea_vote')
    config.add_route('register', '/register')
    config.add_route('login', '/login')
    config.add_route('logout', '/logout')
    config.add_route('about', '/about')
    config.add_route('main', '/')

    config.scan()

    return config.make_wsgi_app()