Ejemplo n.º 1
0
def app(global_config, **settings):
    """ This function returns a WSGI application.
    
    It is usually called by the PasteDeploy framework during 
    ``paster serve``.
    """
    db_string = settings.get('db_string')
    if db_string is None:
        raise ValueError("No 'db_string' value in application configuration.")
    db_echo = settings.get('db_echo', 'false')
    initialize_sql(db_string, asbool(db_echo))
    config = Configurator(settings=settings)
    config.begin()
    config.add_static_view('static', 'tutorial:static')
    config.add_route('home', '/', view='tutorial.views.view_wiki')
    config.add_route('view_page', '/:pagename',
                     view='tutorial.views.view_page',
                     view_renderer='tutorial:templates/view.pt')
    config.add_route('add_page', '/add_page/:pagename',
                     view='tutorial.views.add_page',
                     view_renderer='tutorial:templates/edit.pt')
    config.add_route('edit_page', '/:pagename/edit_page',
                     view='tutorial.views.edit_page',
                     view_renderer='tutorial:templates/edit.pt')
    config.end()
    return config.make_wsgi_app()
Ejemplo n.º 2
0
def main(global_config, **settings):
    """ This function returns a WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    initialize_sql(engine)
    authn_policy = AuthTktAuthenticationPolicy(
        'sosecret', callback=groupfinder)
    authz_policy = ACLAuthorizationPolicy()
    config = Configurator(settings=settings,
                          root_factory='tutorial.models.RootFactory',
                          authentication_policy=authn_policy,
                          authorization_policy=authz_policy)
    config.add_static_view('static', 'tutorial:static')

    config.add_route('view_wiki', '/')
    config.add_route('login', '/login')
    config.add_route('logout', '/logout')
    config.add_route('view_page', '/{pagename}')
    config.add_route('add_page', '/add_page/{pagename}')
    config.add_route('edit_page', '/{pagename}/edit_page')

    config.add_view('tutorial.views.view_wiki', route_name='view_wiki')
    config.add_view('tutorial.login.login', route_name='login', 
                    renderer='tutorial:templates/login.pt')
    config.add_view('tutorial.login.logout', route_name='logout')
    config.add_view('tutorial.views.view_page', route_name='view_page',
                    renderer='tutorial:templates/view.pt')
    config.add_view('tutorial.views.add_page', route_name='add_page',
                    renderer='tutorial:templates/edit.pt', permission='edit')
    config.add_view('tutorial.views.edit_page', route_name='edit_page',
                    renderer='tutorial:templates/edit.pt', permission='edit')
    config.add_view('tutorial.login.login',
                    context='pyramid.httpexceptions.HTTPForbidden',
                    renderer='tutorial:templates/login.pt')
    return config.make_wsgi_app()
Ejemplo n.º 3
0
def app(global_config, **settings):
    """ This function returns a WSGI application.
    
    It is usually called by the PasteDeploy framework during 
    ``paster serve``.
    """
    db_string = settings.get("db_string")
    if db_string is None:
        raise ValueError("No 'db_string' value in application configuration.")
    db_echo = settings.get("db_echo", "false")
    initialize_sql(db_string, asbool(db_echo))
    config = Configurator(settings=settings)
    config.begin()
    config.add_static_view("static", "tutorial:static")
    config.add_route("home", "/", view="tutorial.views.view_wiki")
    config.add_route(
        "view_page", "/:pagename", view="tutorial.views.view_page", view_renderer="tutorial:templates/view.pt"
    )
    config.add_route(
        "add_page", "/add_page/:pagename", view="tutorial.views.add_page", view_renderer="tutorial:templates/view.pt"
    )
    config.add_route(
        "edit_page", "/:pagename/edit_page", view="tutorial.views.edit_page", view_renderer="tutorial:templates/edit.pt"
    )
    config.end()
    return config.make_wsgi_app()
Ejemplo n.º 4
0
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, "sqlalchemy.")
    initialize_sql(engine)
    config = Configurator(settings=settings)
    config.add_static_view("static", "tutorial:static")
    config.add_route("home", "/", view="tutorial.views.my_view", view_renderer="templates/mytemplate.pt")
    return config.make_wsgi_app()
Ejemplo n.º 5
0
def main(global_config, **settings):
    """ This function returns a WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    initialize_sql(engine)
    config = Configurator(settings=settings)
    config.add_static_view('static', 'tutorial:static')
    config.add_route('home', '/', view='tutorial.views.my_view',
                     view_renderer='templates/mytemplate.pt')
    return config.make_wsgi_app()
Ejemplo n.º 6
0
def main(global_config, **settings):
    """ This function returns a WSGI application.
    """
    db_string = settings.get('db_string')
    if db_string is None:
        raise ValueError("No 'db_string' value in application configuration.")
    db_echo = settings.get('db_echo', 'false')
    initialize_sql(db_string, asbool(db_echo))
    config = Configurator(settings=settings)
    config.add_static_view('static', 'tutorial:static')
    config.add_route('home', '/', view='tutorial.views.my_view',
                     view_renderer='templates/mytemplate.pt')
    return config.make_wsgi_app()
Ejemplo n.º 7
0
def main(global_config, **settings):
    """ This function returns a WSGI application.
    """
    engine = engine_from_config(settings, "sqlalchemy.")
    initialize_sql(engine)
    config = Configurator(settings=settings)
    config.add_static_view("static", "tutorial:static", cache_max_age=3600)
    config.add_route("view_wiki", "/")
    config.add_route("view_page", "/{pagename}")
    config.add_route("add_page", "/add_page/{pagename}")
    config.add_route("edit_page", "/{pagename}/edit_page")
    config.add_view("tutorial.views.view_wiki", route_name="view_wiki")
    config.add_view("tutorial.views.view_page", route_name="view_page", renderer="tutorial:templates/view.pt")
    config.add_view("tutorial.views.add_page", route_name="add_page", renderer="tutorial:templates/edit.pt")
    config.add_view("tutorial.views.edit_page", route_name="edit_page", renderer="tutorial:templates/edit.pt")
    return config.make_wsgi_app()
Ejemplo n.º 8
0
def app(global_config, **settings):
    """ This function returns a WSGI application.
    
    It is usually called by the PasteDeploy framework during 
    ``paster serve``.
    """
    zcml_file = settings.get('configure_zcml', 'configure.zcml')
    db_string = settings.get('db_string')
    if db_string is None:
        raise ValueError(
            "No 'db_string' value in application configuration.")
    db_echo = settings.get('db_echo', 'false')
    initialize_sql(db_string, asbool(db_echo))
    config = Configurator(settings=settings)
    config.begin()
    config.load_zcml(zcml_file)
    config.end()
    return config.make_wsgi_app()
Ejemplo n.º 9
0
def main(global_config, **settings):
    """ This function returns a WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    initialize_sql(engine)
    config = Configurator(settings=settings)
    config.add_static_view('static', 'tutorial:static')
    config.add_route('view_wiki', '/', view='tutorial.views.view_wiki')
    config.add_route('view_page', '/{pagename}',
                     view='tutorial.views.view_page',
                     view_renderer='tutorial:templates/view.pt')
    config.add_route('add_page', '/add_page/{pagename}',
                     view='tutorial.views.add_page',
                     view_renderer='tutorial:templates/edit.pt')
    config.add_route('edit_page', '/{pagename}/edit_page',
                     view='tutorial.views.edit_page',
                     view_renderer='tutorial:templates/edit.pt')
    return config.make_wsgi_app()
Ejemplo n.º 10
0
def app(global_config, **settings):
    """ This function returns a WSGI application.
    
    It is usually called by the PasteDeploy framework during 
    ``paster serve``.
    """
    db_string = settings.get('db_string')
    if db_string is None:
        raise ValueError("No 'db_string' value in application configuration.")
    db_echo = settings.get('db_echo', 'false')
    initialize_sql(db_string, asbool(db_echo))
    authn_policy = AuthTktAuthenticationPolicy(
        'sosecret', callback=groupfinder)
    authz_policy = ACLAuthorizationPolicy()
    config = Configurator(settings=settings,
                          root_factory='tutorial.models.RootFactory',
                          authentication_policy=authn_policy,
                          authorization_policy=authz_policy)
    config.begin()
    config.add_static_view('static', 'tutorial:static')
    config.add_route('view_wiki', '/', view='tutorial.views.view_wiki')
    config.add_route('login', '/login',
                     view='tutorial.login.login',
                     view_renderer='tutorial:templates/login.pt')
    config.add_route('logout', '/logout',
                     view='tutorial.login.logout')
    config.add_route('view_page', '/:pagename',
                     view='tutorial.views.view_page',
                     view_renderer='tutorial:templates/view.pt')
    config.add_route('add_page', '/add_page/:pagename',
                     view='tutorial.views.add_page',
                     view_renderer='tutorial:templates/edit.pt',
                     view_permission='edit')
    config.add_route('edit_page', '/:pagename/edit_page',
                     view='tutorial.views.edit_page',
                     view_renderer='tutorial:templates/edit.pt',
                     view_permission='edit')
    config.add_view('tutorial.login.login',
                    renderer='tutorial:templates/login.pt',
                    context='pyramid.exceptions.Forbidden')
    config.end()
    return config.make_wsgi_app()
Ejemplo n.º 11
0
def main(global_config, **settings):
    """ This function returns a WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    initialize_sql(engine)
    authn_policy = AuthTktAuthenticationPolicy('sosecret',
                                               callback=groupfinder)
    authz_policy = ACLAuthorizationPolicy()
    config = Configurator(settings=settings,
                          root_factory='tutorial.models.RootFactory',
                          authentication_policy=authn_policy,
                          authorization_policy=authz_policy)
    config.add_static_view('static', 'tutorial:static')

    config.add_route('view_wiki', '/')
    config.add_route('login', '/login')
    config.add_route('logout', '/logout')
    config.add_route('view_page', '/{pagename}')
    config.add_route('add_page', '/add_page/{pagename}')
    config.add_route('edit_page', '/{pagename}/edit_page')

    config.add_view('tutorial.views.view_wiki', route_name='view_wiki')
    config.add_view('tutorial.login.login',
                    route_name='login',
                    renderer='tutorial:templates/login.pt')
    config.add_view('tutorial.login.logout', route_name='logout')
    config.add_view('tutorial.views.view_page',
                    route_name='view_page',
                    renderer='tutorial:templates/view.pt')
    config.add_view('tutorial.views.add_page',
                    route_name='add_page',
                    renderer='tutorial:templates/edit.pt',
                    permission='edit')
    config.add_view('tutorial.views.edit_page',
                    route_name='edit_page',
                    renderer='tutorial:templates/edit.pt',
                    permission='edit')
    config.add_view('tutorial.login.login',
                    context='pyramid.exceptions.Forbidden',
                    renderer='tutorial:templates/login.pt')
    return config.make_wsgi_app()
Ejemplo n.º 12
0
def main(global_config, **settings):
    """ This function returns a WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    initialize_sql(engine)
    config = Configurator(settings=settings)
    config.add_static_view('static', 'tutorial:static')
    config.add_route('view_wiki', '/', view='tutorial.views.view_wiki')
    config.add_route('view_page',
                     '/{pagename}',
                     view='tutorial.views.view_page',
                     view_renderer='tutorial:templates/view.pt')
    config.add_route('add_page',
                     '/add_page/{pagename}',
                     view='tutorial.views.add_page',
                     view_renderer='tutorial:templates/edit.pt')
    config.add_route('edit_page',
                     '/{pagename}/edit_page',
                     view='tutorial.views.edit_page',
                     view_renderer='tutorial:templates/edit.pt')
    return config.make_wsgi_app()
Ejemplo n.º 13
0
def main(global_config, **settings):
    """ This function returns a WSGI application.
    """
    engine = engine_from_config(settings, "sqlalchemy.")
    initialize_sql(engine)
    authn_policy = AuthTktAuthenticationPolicy("sosecret", callback=groupfinder)
    authz_policy = ACLAuthorizationPolicy()
    config = Configurator(
        settings=settings,
        root_factory="tutorial.models.RootFactory",
        authentication_policy=authn_policy,
        authorization_policy=authz_policy,
    )
    config.add_static_view("static", "tutorial:static", cache_max_age=3600)

    config.add_route("view_wiki", "/")
    config.add_route("login", "/login")
    config.add_route("logout", "/logout")
    config.add_route("view_page", "/{pagename}")
    config.add_route("add_page", "/add_page/{pagename}")
    config.add_route("edit_page", "/{pagename}/edit_page")

    config.add_view("tutorial.views.view_wiki", route_name="view_wiki")
    config.add_view("tutorial.login.login", route_name="login", renderer="tutorial:templates/login.pt")
    config.add_view("tutorial.login.logout", route_name="logout")
    config.add_view("tutorial.views.view_page", route_name="view_page", renderer="tutorial:templates/view.pt")
    config.add_view(
        "tutorial.views.add_page", route_name="add_page", renderer="tutorial:templates/edit.pt", permission="edit"
    )
    config.add_view(
        "tutorial.views.edit_page", route_name="edit_page", renderer="tutorial:templates/edit.pt", permission="edit"
    )
    config.add_view(
        "tutorial.login.login", context="pyramid.httpexceptions.HTTPForbidden", renderer="tutorial:templates/login.pt"
    )
    return config.make_wsgi_app()
Ejemplo n.º 14
0
def _initTestingDB():
    from tutorial.models import initialize_sql
    session = initialize_sql('sqlite://')
    return session
Ejemplo n.º 15
0
def _initTestingDB():
    from sqlalchemy import create_engine
    from tutorial.models import initialize_sql
    session = initialize_sql(create_engine('sqlite://'))
    return session
Ejemplo n.º 16
0
    def _callFUT(self, engine):
        from tutorial.models import initialize_sql

        return initialize_sql(engine)
Ejemplo n.º 17
0
def _initTestingDB():
    from tutorial.models import initialize_sql
    session = initialize_sql('sqlite://')
    return session
Ejemplo n.º 18
0
def _initTestingDB():
    from sqlalchemy import create_engine
    from tutorial.models import initialize_sql
    session = initialize_sql(create_engine('sqlite://'))
    return session