Exemple #1
0
from lp.services.config import dbconfig
from lp.services.database.sqlbase import cursor
from lp.services.scripts import execute_zcml_for_scripts
from lp.testing.layers import disconnect_stores

execute_zcml_for_scripts()


def check():
    cur = cursor()
    cur.execute("UPDATE Person SET homepage_content='foo' WHERE name='mark'")
    cur.execute("SHOW transaction_isolation")
    print cur.fetchone()[0]

    transaction.abort()
    transaction.begin()

    cur = cursor()
    cur.execute("UPDATE Person SET homepage_content='bar' WHERE name='mark'")
    cur.execute("SHOW transaction_isolation")
    print cur.fetchone()[0]

dbconfig.override(dbuser='******', isolation_level='read_committed')
disconnect_stores()
check()

dbconfig.override(isolation_level='repeatable_read')
disconnect_stores()
check()
from lp.services.config import dbconfig
from lp.services.database.sqlbase import cursor
from lp.services.scripts import execute_zcml_for_scripts
from lp.testing.layers import disconnect_stores

execute_zcml_for_scripts()


def check():
    cur = cursor()
    cur.execute("UPDATE Person SET homepage_content='foo' WHERE name='mark'")
    cur.execute("SHOW transaction_isolation")
    print cur.fetchone()[0]

    transaction.abort()
    transaction.begin()

    cur = cursor()
    cur.execute("UPDATE Person SET homepage_content='bar' WHERE name='mark'")
    cur.execute("SHOW transaction_isolation")
    print cur.fetchone()[0]

dbconfig.override(dbuser='******', isolation_level='read_committed')
disconnect_stores()
check()

dbconfig.override(isolation_level='repeatable_read')
disconnect_stores()
check()
def set_isolation_level(isolation):
    dbconfig.override(isolation_level=isolation)
    disconnect_stores()
def set_isolation_level(isolation):
    dbconfig.override(isolation_level=isolation)
    disconnect_stores()