with_transaction may skip transaction function when ommiting parameters
|Reported by:||Owned by:|
Using the decorator
@with_transaction without parameters skips the transaction function at all. This just happend to me by accident and it took me a while to figure out, why the function was being skipped.
Here's some example code:
def my_method(self): from trac.db import with_transaction print "Before do_transaction" # No parantheses by accident @with_transaction def do_transaction(cnx): print "In do_transaction" print "After do_transaction"
Running this method just outputs:
Before do_transaction After do_transaction
The transaction function
do_transaction() is completely skipped.
I've attached a patch that raises an exception in this case.
This patch also "corrects" the use of a deprecated function. Sorry for that but I was too lazy to create a new ticket for this.