Exemplo n.º 1
0
 def connect_database(self):
     """ Use sqlalchemy to connect directly to the database file on
     disk.
     """
     from sqlalchemy import create_engine
     engine = create_engine("sqlite:///config/cookbook.sqlite")
     DBSession.configure(bind=engine)
     Base.metadata.create_all(engine)
     return DBSession
Exemplo n.º 2
0
def main(argv=sys.argv):
    """ Create a completely empty database."""
    if len(argv) < 2:
        usage(argv)
    config_uri = argv[1]
    options = parse_vars(argv[2:])
    setup_logging(config_uri)
    settings = get_appsettings(config_uri, options=options)
    engine = engine_from_config(settings, "sqlalchemy.")
    DBSession.configure(bind=engine)
    Base.metadata.create_all(engine)
Exemplo n.º 3
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

    auth_tkt_pol = AuthTktAuthenticationPolicy
    authentication_policy = auth_tkt_pol(auth_policy_secret,
                                         callback=access_verifier,
                                         hashalg='sha512')
    authorization_policy = ACLAuthorizationPolicy()


    config = Configurator(settings=settings,
                          root_factory="cookbook.models.RootFactory",
                          authentication_policy=authentication_policy,
                          authorization_policy=authorization_policy)

    config.include("pyramid_chameleon")

    # Static assets include thumbnails, turn off caching to ensure they
    # are reloaded in a timely fashion
    config.add_static_view("assets", "assets", cache_max_age=1)


    config.add_route("file_add", "/file_add/{checkout_id}")
    config.add_route("file_view", "/file_view/{checkout_id}/{filename}")

    config.add_route("checkout_list", "/checkout_list/")
    config.add_route("checkout_add", "/checkout_add/")
    config.add_route("checkout_view", "/checkout/{checkout_id}")
    config.add_route("checkout_delete",
                     "/checkout_delete/{checkout_id}")


    config.add_route("login", "/login/google")
    config.add_route("logout", "/logout/google")
    config.add_route("user_view", "/user_view/")

    config.add_route("analyze_view", "/analyze/")
    config.add_route("analyze_long_term_view", "/analyze_long_term/")

    config.add_route("serial_view", "/{serial}")
    config.add_route("home_redirect", "/")

    config.scan("cookbook.views")
    return config.make_wsgi_app()