def session(request): engine = init_engine() Base.metadata.create_all(engine) def drop_all(): Base.metadata.drop_all(engine) request.addfinalizer(drop_all) return init_session(engine=engine)
def __init__(self, db_url=None, session=None, settings=None): """ :param db_url: engine configuration that is in the 'Database URL' format as supported by SQLAlchemy: http://docs.sqlalchemy.org/en/latest/core/engines.html#database-urls :type db_url: string """ if session is None: self.Session = init_session(db_url=db_url, settings=settings) else: self.Session = session
role_membership, role_permission, ) import datetime from sqlalchemy import case, func, distinct from passlib.context import CryptContext from yosai.core import LazySettings settings = LazySettings(env_var='YOSAI_SETTINGS') engine = init_engine(settings=settings) Base.metadata.drop_all(engine) Base.metadata.create_all(engine) import pprint pp = pprint.PrettyPrinter(indent=1) Session = init_session(settings=settings) # Please watch 'The Big Lebowski' so that you may understand the following data. users = [User(first_name='Jeffrey', last_name='Lebowski', identifier='thedude', phone_number='11234567890'), User(first_name='Walter', last_name='Sobchak', identifier='walter'), User(first_name='Larry', last_name='Sellers', identifier='larry'), User(first_name='Jackie', last_name='Treehorn', identifier='jackie'), User(first_name='Karl', last_name='Hungus', identifier='karl'), User(first_name='Marty', last_name='Houston', identifier='marty')] domains = [Domain(name='money'), Domain(name='leatherduffelbag')] actions = [Action(name='write'), Action(name='deposit'), Action(name='transport'),
role_membership, role_permission, ) import datetime from sqlalchemy import case, func, distinct from passlib.context import CryptContext from yosai.core import LazySettings settings = LazySettings(env_var='YOSAI_SETTINGS') engine = init_engine(settings=settings) Base.metadata.drop_all(engine) Base.metadata.create_all(engine) import pprint pp = pprint.PrettyPrinter(indent=1) Session = init_session(settings=settings) # Please watch 'The Big Lebowski' so that you may understand the following data. users = [ User(first_name='Jeffrey', last_name='Lebowski', identifier='thedude', phone_number='11234567890'), User(first_name='Walter', last_name='Sobchak', identifier='walter'), User(first_name='Larry', last_name='Sellers', identifier='larry'), User(first_name='Jackie', last_name='Treehorn', identifier='jackie'), User(first_name='Karl', last_name='Hungus', identifier='karl'), User(first_name='Marty', last_name='Houston', identifier='marty') ] domains = [Domain(name='money'), Domain(name='leatherduffelbag')]
def session(cache_handler, request, settings): session_maker = init_session(settings=settings) session = session_maker() return session