Comment 1 for bug 125118

Revision history for this message
Anand Chitipothu (anandology) wrote :

Consider the following code:

def f():
    web.transact()
    try:
        g()
    except:
        web.rollback()
    else:
        web.commit()

def g():
    web.transact()
     h()
     web.commit()

def h():
    raise Exception

Since g, didn't do rollback, the rollback in f is not really rolling back the correct transaction.

How about the following interface?

t = web.transact()
try:
    web.query('blah blah blah')
except:
    t.rollback()
    raise
else:
    t.commit()

Here we know what to rollback, so even if it is rolled back twice, it can be handled.

shall we consider it for web.py 0.3?