Esempio n. 1
0
def main(argv=sys.argv):
    if len(argv) != 2:
        usage(argv)
    config_uri = argv[1]
    setup_logging(config_uri)
    settings = get_appsettings(config_uri)
    engine = engine_from_config(settings, 'sqlalchemy.')
    initialize_sql(engine)
    session = DBSession()
    #DBSession.configure(bind=engine)
    #Base.metadata.create_all(engine)
    with transaction.manager:
        for event in Event.query.all():
            m = normalize_model(event)
            session.add(m)
Esempio n. 2
0
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    database_url = os.environ.get('ALMANAC_DATABASE_URL')
    if database_url:
        settings['sqlalchemy.url'] = database_url
    engine = engine_from_config(settings, 'sqlalchemy.')
    initialize_sql(engine)
    config = Configurator(settings=settings)
    config.add_tween('pyramid_spine.tweens.timezone_tween_factory')
    config.include('pyramid_jinja2')
    config.add_renderer('.html', factory='pyramid_jinja2.renderer_factory')
    config.add_jinja2_search_path("almanac:templates")

    config.include('almanac.events', route_prefix="/events")
    config.add_static_view('static', 'static', cache_max_age=3600)
    config.add_route('home', '/')
    config.scan()

    return config.make_wsgi_app()