def begin(self, unloading=False): """Begin loading data - creates and stores a connection with engine.connect() if an engine was passed - binds the connection or engine to fixture's internal session - uses an unbound internal session if no engine or connection was passed in """ if not unloading: # ...then we are loading, so let's *lazily* # clean up after a previous setup/teardown Session.remove() if self.connection is None and self.engine is None: if self.session: self.engine = self.session.bind # might be None if self.engine is not None and self.connection is None: self.connection = self.engine.connect() if self.session is None: if self.connection: self.session = self.Session(bind=self.connection) else: self.session = self.Session(bind=None) DBLoadableFixture.begin(self, unloading=unloading)
def __init__(self, connection=None, use_transaction=True, close_conn=False, **kw): DBLoadableFixture.__init__(self, **kw) self.connection = connection self.close_conn = close_conn self.use_transaction = use_transaction
def __init__(self, store=None, use_transaction=True, close_store=False, **kw): DBLoadableFixture.__init__(self, **kw) self.store = store self.close_store = close_store self.use_transaction = use_transaction
def __init__(self, session=None, scoped_session=None, connection=None, **kw): DBLoadableFixture.__init__(self, **kw) self.session = session self.scoped_session = scoped_session self.connection = connection
def commit(self): """Commit the load transaction and flush the session """ if self.connection: # note that when not using a connection, calling session.commit() # as the inheirted code does will automatically flush the session self.session.flush() log.debug("transaction.commit() <- %s", self.transaction) DBLoadableFixture.commit(self)
def __init__(self, engine=None, connection=None, session=None, scoped_session=None, **kw): # ensure import error by simulating what would happen in the global module : from sqlalchemy.orm import sessionmaker, scoped_session as sa_scoped_session DBLoadableFixture.__init__(self, **kw) self.engine = engine self.connection = connection self.session = session if scoped_session is None: scoped_session = Session self.Session = scoped_session
def commit(self): """Commit the load transaction and flush the session """ if self.connection: # note that when not using a connection, calling session.commit() # as the inheirted code does will automatically flush the session self.session.flush() # this is a hack because I can't get transaction.commit # to actually do anything for me... self.session.commit() log.debug("transaction.commit() <- %s", self.transaction) DBLoadableFixture.commit(self)
def begin(self, unloading=False): if self.session is None and self.scoped_session is None: raise UninitializedError( "%s must be assigned either a session or session_context" % (self.__class__.__name__)) if self.scoped_session is not None: self.session = self.scoped_session() #if self.session is None: # self.session = self.scoped_session() if not self.connection and self.session.bind is not None: self.connection = self.session.bind.connect() DBLoadableFixture.begin(self, unloading=unloading)
def commit(self): """Commit transaction""" if self.use_transaction: DBLoadableFixture.commit(self)
def __init__(self, **kw): if not kw.get('env', None): kw['env'] = DjangoEnv DBLoadableFixture.__init__(self, **kw)
def rollback(self): if self.use_transaction: DBLoadableFixture.rollback(self)
def commit(self): if self.use_transaction: DBLoadableFixture.commit(self)
def commit(self): self.session.flush() DBLoadableFixture.commit(self)
def rollback(self): """Rollback load transaction""" DBLoadableFixture.rollback(self)
def __init__(self, **kw): if not kw.get("env", None): kw["env"] = DjangoEnv DBLoadableFixture.__init__(self, **kw)
def __init__(self, store=None, use_transaction=True, close_store=False, **kw ): DBLoadableFixture.__init__(self, **kw) self.store = store self.close_store = close_store self.use_transaction = use_transaction
def __init__(self, connection=None, use_transaction=True, close_conn=False, **kw ): DBLoadableFixture.__init__(self, **kw) self.connection = connection self.close_conn = close_conn self.use_transaction = use_transaction
def rollback(self): """Rollback the transaction""" if self.use_transaction: DBLoadableFixture.rollback(self)
def rollback(self): DBLoadableFixture.rollback(self)