Beispiel #1
0
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)

    # pyramid_beaker add-on
    session_factory = session_factory_from_settings(settings)
    authn_policy = SessionAuthenticationPolicy()
    authz_policy = ACLAuthorizationPolicy()
    Base.metadata.bind = engine
 
    config = Configurator(
        settings=settings,
        root_factory=RootFactory,
        authentication_policy=authn_policy,
        authorization_policy=authz_policy,
        session_factory=session_factory,
        )

    config.add_static_view('static', 'static', cache_max_age=3600)
#    config.add_subscriber(add_renderer_globals, BeforeRender)
    # mako settings for file extension .html
    config.add_renderer(".html", "pyramid.mako_templating.renderer_factory")
    config.include(addroutes)
    config.scan()
    return config.make_wsgi_app()
Beispiel #2
0
 def setUp(self):
     self.config = testing.setUp()
     from sqlalchemy import create_engine
     engine = create_engine('sqlite://')
     from .models import (
         Base,
         MyModel,
         )
     DBSession.configure(bind=engine)
     Base.metadata.create_all(engine)
     with transaction.manager:
         model = MyModel(name='one', value=55)
         DBSession.add(model)
Beispiel #3
0
 def setUp(self):
     self.config = testing.setUp()
     from sqlalchemy import create_engine
     engine = create_engine('sqlite://')
     from .models import (
         Base,
         MyModel,
     )
     DBSession.configure(bind=engine)
     Base.metadata.create_all(engine)
     with transaction.manager:
         model = MyModel(name='one', value=55)
         DBSession.add(model)
Beispiel #4
0
 def tearDown(self):
     DBSession.remove()
     testing.tearDown()
Beispiel #5
0
 def tearDown(self):
     DBSession.remove()
     testing.tearDown()