The !WikiPage public API is not modified. A helper `transaction` function is used to factor out the `handle_ta` business. Its usage is very simple:
- if the function is given a database connection, it will simply execute the callback as part of another transaction,
- if the function has to retrieve a new database connection, it takes responsibility to either `commit` the changes performed by the callback or to `rollback` them, if any exception was raised.
TODO: similar changes could apply to `trac.ticket.model`