示例#1
0
def init(file_path, url, engine_options={}, create_tables=False):
    """Connect mappings to the database"""
    # Load the appropriate db module
    load_egg_for_url(url)
    # Create the database engine
    engine = create_engine(url, **engine_options)
    # Connect the metadata to the database.
    metadata.bind = engine
    # Clear any existing contextual sessions and reconfigure
    Session.remove()
    Session.configure(bind=engine)
    # Create tables if needed
    if create_tables:
        metadata.create_all()
    # Pack everything into a bunch
    result = Bunch(**globals())
    result.engine = engine
    result.session = Session
    result.create_tables = create_tables
    # Load local tool shed security policy
    result.security_agent = CommunityRBACAgent(result)
    result.shed_counter = shed_statistics.ShedCounter(result)
    result.hgweb_config_manager = galaxy.webapps.tool_shed.util.hgweb_config.HgWebConfigManager(
    )
    return result
示例#2
0
def init( file_path, url, engine_options={}, create_tables=False ):
    """Connect mappings to the database"""
    # Create the database engine
    engine = build_engine( url, engine_options )
    # Connect the metadata to the database.
    metadata.bind = engine

    result = ModelMapping([galaxy.webapps.tool_shed.model], engine=engine)

    if create_tables:
        metadata.create_all()

    result.create_tables = create_tables

    # Load local tool shed security policy
    result.security_agent = CommunityRBACAgent( result )
    result.shed_counter = shed_statistics.ShedCounter( result )
    result.hgweb_config_manager = galaxy.webapps.tool_shed.util.hgweb_config.HgWebConfigManager()
    return result