def get_session(autocommit=True, expire_on_commit=False): """Return a SQLAlchemy session.""" global _MAKER if _MAKER is None: engine = get_engine() _MAKER = nova_session.get_maker(engine, autocommit, expire_on_commit) session = _MAKER() return session
def get_session(autocommit=True, expire_on_commit=False): """Return a SQLAlchemy session.""" global _MAKER if _MAKER is None: engine = get_engine() _MAKER = get_maker(engine, autocommit, expire_on_commit) session = _MAKER() session.query = nova.exception.wrap_db_error(session.query) session.flush = nova.exception.wrap_db_error(session.flush) return session