Since I am already doing some hacking on expose (moving the validator
and inputform functionality out to separate decorators) I thought I'd
pick this one up.
Fantastic! This is probably my biggest gripe with TurboGears right
now, and I really was hoping someone would step up and work on this!
My question is - do we want this on by default, or do we want to
explicitly enable it with a parameter to expose?
<snip snip>
Obviously the latter is backwards compatible, but if everyone is going
to want a transaction for all of their controller methods, maybe it
should be enabled by default?
I for one *expected* it to be on by default, if not only because it
is desired behavior for most cases that I can think of. In my
current project, it would reduce the size of my controllers by at
least 50%.
I do have a question for you: how are you going to handle Exceptions
and the ability to display nice errors with `flash`? Typically, I
end up with a try:except:finally block where I `flash('some nice
error message')` and do a `hub.rollback()`. I may have a different
error message for different types of Exceptions...
Maybe this could be handled sort of like validators?
@turbogears.expose(transaction=True,
err_map={Exception : 'generic msg',
SQLObjectNotFound : 'specific msg'}
def my_method(self):
frob = frobbler.frobble()
return dict(frob=frob)
On an exception being raised, the transaction would automatically be
rolled back, and the appropriate error message would be flashed on
the page. Just thinking out loud, and this obviously isn't perfect.
But, its an important wrinkle to figure out.
-- Jon