Example #1
0
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = engine_from_config(settings, 'sqlalchemy.')
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine
    session_factory = UnencryptedCookieSessionFactoryConfig(
        settings['secret_key'])
    config = Configurator(settings=settings,
                          root_factory='composting.models.base.RootFactory',
                          session_factory=session_factory)
    config.set_authentication_policy(
        AuthTktAuthenticationPolicy(settings['secret_key'],
                                    callback=group_finder,
                                    hashalg='sha512'))

    config.set_authorization_policy(ACLAuthorizationPolicy())
    config.set_default_permission('authenticated')

    logging.config.fileConfig(global_config['__file__'],
                              disable_existing_loggers=False)

    # configure password context
    pwd_context.load_path(global_config['__file__'])

    # include ourselves
    includeme(config)
    return config.make_wsgi_app()
Example #2
0
 def setUp(self):
     registry = Registry()
     registry.settings = settings
     self.config = testing.setUp(registry=registry)
     pwd_context.load_path('test.ini')
     # setup db
     DBSession.configure(bind=engine, expire_on_commit=False)
     Base.metadata.bind = engine
     Base.metadata.drop_all()
     Base.metadata.create_all()
     # enable logging
     logging.config.fileConfig('test.ini', disable_existing_loggers=False)