Example #1
0
 def setUp(self):
     self.mappers = setup_mappers()
     metadata.drop_all(engine)
     metadata.create_all(engine)
     self.tm1 = transaction.TransactionManager()
     self.tm2 = transaction.TransactionManager()
     # With psycopg2 you might supply isolation_level='SERIALIZABLE' here,
     # unfortunately that is not supported by cx_Oracle.
     e1 = sa.create_engine(TEST_DSN)
     e2 = sa.create_engine(TEST_DSN)
     self.s1 = orm.sessionmaker(bind=e1, twophase=TEST_TWOPHASE)()
     tx.register(self.s1, transaction_manager=self.tm1)
     self.s2 = orm.sessionmaker(bind=e2, twophase=TEST_TWOPHASE)()
     tx.register(self.s2, transaction_manager=self.tm2)
     self.tm1.begin()
     self.s1.add(User(id=1, firstname="udo", lastname="juergens"))
     self.tm1.commit()
Example #2
0
    ))

EventSession = orm.scoped_session(
    orm.sessionmaker(
        bind=engine,
        twophase=TEST_TWOPHASE,
    ))

KeepSession = orm.scoped_session(
    orm.sessionmaker(
        bind=engine,
        extension=tx.ZopeTransactionExtension(keep_session=True),
        twophase=TEST_TWOPHASE,
    ))

tx.register(EventSession)

metadata = sa.MetaData()  # best to use unbound metadata

test_users = sa.Table(
    'test_users',
    metadata,
    sa.Column('id', sa.Integer, primary_key=True),
    sa.Column('firstname',
              sa.VARCHAR(255)),  # mssql cannot do equality on a text type
    sa.Column('lastname', sa.VARCHAR(255)),
)

test_skills = sa.Table(
    'test_skills',
    metadata,
Example #3
0
            HAS_PATCHED_PYSQLITE = True

if HAS_PATCHED_PYSQLITE:
    from sqlalchemy import event
    from zope.sqlalchemy.datamanager import NO_SAVEPOINT_SUPPORT

    NO_SAVEPOINT_SUPPORT.remove("sqlite")

    @event.listens_for(engine, "connect")
    def connect(dbapi_connection, connection_record):
        dbapi_connection.operation_needs_transaction_callback = lambda x: True


Session = orm.scoped_session(
    orm.sessionmaker(bind=engine, twophase=TEST_TWOPHASE))
tx.register(Session)

UnboundSession = orm.scoped_session(orm.sessionmaker(twophase=TEST_TWOPHASE))
tx.register(UnboundSession)

EventSession = orm.scoped_session(
    orm.sessionmaker(bind=engine, twophase=TEST_TWOPHASE))
tx.register(EventSession)

KeepSession = orm.scoped_session(
    orm.sessionmaker(bind=engine, twophase=TEST_TWOPHASE))
tx.register(KeepSession, keep_session=True)

metadata = sa.MetaData()  # best to use unbound metadata

test_users = sa.Table(
Example #4
0
    extension=tx.ZopeTransactionExtension(),
    twophase=TEST_TWOPHASE,
))

EventSession = orm.scoped_session(orm.sessionmaker(
    bind=engine,
    twophase=TEST_TWOPHASE,
))

KeepSession = orm.scoped_session(orm.sessionmaker(
    bind=engine,
    extension=tx.ZopeTransactionExtension(keep_session=True),
    twophase=TEST_TWOPHASE,
))

tx.register(EventSession)

metadata = sa.MetaData()  # best to use unbound metadata


test_users = sa.Table(
    'test_users',
    metadata,
    sa.Column('id', sa.Integer, primary_key=True),
    sa.Column('firstname', sa.VARCHAR(255)),  # mssql cannot do equality on a text type
    sa.Column('lastname', sa.VARCHAR(255)),
)

test_skills = sa.Table(
    'test_skills',
    metadata,