Chris McDonough wrote:
> Re-added to list...
> Alberto Valverde wrote:
>>> Mark Ramm wrote:
>>>> So, we're finally getting around to handling transactions in
>>>> middleware in tg2, and Alberto and I have been playing with different
>>>> variations on the theme, and ultimately I think it might be
>>>> good if we had a transaction middleware that provided a bit more
>>>> configurability about when it rolls back transactions.
>>> +1
>>>> Alberto added something which checked the HTTP status code for error
>>>> codes and rolled back when the app indicated that an error had
>>>> occurred (useful when there's middleware that catches and handles
>>>> python exceptions), and I was playing with the idea of setting some
>>>> kind of semi-standard parameter in the environ that signals that
>>>> there's been an error somewhere and the transaction should be rolled
>>>> back.
>>> There is an existing pattern for this if you can get a hold of the
>>> transaction
>>> object itself in app code:  transaction.doom()
>> This is good for the cases where the middleware stacked below
>> knows about the transaction, but worthless otherwise.
> Any app code can doom the current transaction, actually by an import and a 
> couple of function calls:
> import transaction
> transaction.get().doom()

Tres reminded me that this can also be accomplished by the shortcut:

import transaction

- C

Repoze-dev mailing list

Reply via email to