1
= ZopelessTransactionManager =
3
The ZopelessTransactionManager used to be an alternative to the Zope
4
transaction manager and SQLOS database adapter.
6
With the move to Storm, it was converted to a small compatibility shim
7
used to configure the database adapter.
11
The ZopelessTransactionManager is initialized with its initZopeless()
14
>>> from canonical.database.sqlbase import ZopelessTransactionManager
15
>>> ZopelessTransactionManager.initZopeless(dbuser='launchpad_main')
17
After initZopeless() has been called, the '_installed' attribute of
18
ZopelessTransactionManager will be set to the transaction manager:
20
>>> ZopelessTransactionManager._installed is ZopelessTransactionManager
23
The initZopeless() call defaults to read committed isolation:
25
>>> from canonical.database.sqlbase import cursor
27
>>> c.execute("SHOW transaction_isolation")
28
>>> print c.fetchone()[0]
31
The uninstall() method can be used to uninstall the transaction
34
>>> ZopelessTransactionManager.uninstall()
35
>>> print ZopelessTransactionManager._installed
38
We can log in as alternative users with initZopeless():
40
>>> ZopelessTransactionManager.initZopeless(dbuser='testadmin')
42
>>> c.execute("SELECT current_user")
43
>>> print c.fetchone()[0]
45
>>> ZopelessTransactionManager.uninstall()
47
Or we can specify other transaction isolation modes:
49
>>> from canonical.database.sqlbase import (
50
... ISOLATION_LEVEL_SERIALIZABLE)
51
>>> ZopelessTransactionManager.initZopeless(
52
... dbuser='librarian', isolation=ISOLATION_LEVEL_SERIALIZABLE)
54
>>> c.execute("SHOW transaction_isolation")
55
>>> print c.fetchone()[0]
57
>>> ZopelessTransactionManager.uninstall()