示例#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.community.util.hgweb_config.HgWebConfigManager(
    )
    return result
示例#2
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 galaxy security policy
    result.security_agent = CommunityRBACAgent( result )
    result.shed_counter = ShedCounter( result )
    return result