Ejemplo n.º 1
0
def run_migrations_online():
    """Run migrations in 'online' mode.

    In this scenario we need to create an Engine
    and associate a connection with the context.

    """
    connectable = get_db_engine()

    with connectable.connect() as connection:
        context.configure(
            connection=connection,
            target_metadata=target_metadata
        )

        with context.begin_transaction():
            context.run_migrations()
Ejemplo n.º 2
0
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    engine = get_db_engine()
    DBSession.configure(bind=engine)
    Base.metadata.bind = engine

    authentication_policy = AuthTktAuthenticationPolicy(
        AUTH_SECRET,
        callback=get_principal_indentifiers,
    )
    authorization_policy = ACLAuthorizationPolicy()

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

    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_static_view(name='media', path=MEDIA_ROOT, cache_max_age=3600)

    # Update redis.sessions.url
    config.registry.settings['redis.sessions.url'] = get_redis_url()

    config.include('pyramid_redis_sessions')
    config.include('pyramid_jinja2')

    # Add .html extension as a renderer
    config.add_jinja2_renderer('.html')

    # Scan views for route configuration
    config.include('polls.views.polls')
    config.include('polls.views.auth')

    config.scan()

    return config.make_wsgi_app()
Ejemplo n.º 3
0
    get_db_connection_url,
    get_db_engine
)
from polls.models.meta.base import (
    Base,
    DBSession
)


# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config


# Get sqlalchemy database engine from settings
db_engine = get_db_engine()

# Bind newly created engine to DBSession
DBSession.configure(bind=db_engine)

# Bind base model with database
Base.metadata.bind = db_engine


# Interpret the config file for Python logging.
# This line sets up loggers basically.
fileConfig(config.config_file_name)

# add your model's MetaData object here
# for 'autogenerate' support
# from myapp import mymodel