本文整理汇总了Python中galaxy.util.bunch.Bunch.session方法的典型用法代码示例。如果您正苦于以下问题:Python Bunch.session方法的具体用法?Python Bunch.session怎么用?Python Bunch.session使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类galaxy.util.bunch.Bunch
的用法示例。
在下文中一共展示了Bunch.session方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init
# 需要导入模块: from galaxy.util.bunch import Bunch [as 别名]
# 或者: from galaxy.util.bunch.Bunch import session [as 别名]
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
示例2: Bunch
# 需要导入模块: from galaxy.util.bunch import Bunch [as 别名]
# 或者: from galaxy.util.bunch.Bunch import session [as 别名]
import sys
sys.path.insert(1,'/galaxy-central')
sys.path.insert(1,'/galaxy-central/lib')
from scripts.db_shell import *
from galaxy.util.bunch import Bunch
from galaxy.security import GalaxyRBACAgent
from sqlalchemy.orm import sessionmaker
from sqlalchemy import *
import argparse
bunch = Bunch( **globals() )
engine = create_engine('postgres://galaxy:[email protected]:5432/galaxy')
bunch.session = sessionmaker(bind=engine)
# For backward compatibility with "model.context.current"
bunch.context = sessionmaker(bind=engine)
security_agent = GalaxyRBACAgent( bunch )
security_agent.sa_session = sa_session
def add_user(email, password, key=None):
"""
Add Galaxy User.
From John https://gist.github.com/jmchilton/4475646
"""
query = sa_session.query( User ).filter_by( email=email )
if query.count() > 0:
return query.first()
else:
User.use_pbkdf2 = False
user = User(email)