Hash: SHA1

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 repoze.tm 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.
> 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.

You can also call 'doom' on the transaction, e.g.:

  import transaction

which will prevent any commit from occurring for the current
transaction, no matter what.

> Of course if we're relying on some kind of "special key" in the
> environ, repoze.tm it couples the application inside to repoze.tm a
> little bit, so I like Alberto's way better.   On the other hand, I
> don't think every application will want the mapping of response-codes
> to rollback, and it's even more likely that some folks will want to be
> able to handle that mapping a bit differently than any default we come
> up with.
> And the benifit of a special key in the environ is that it allows
> users to overide the default behavior for a particular request, which
> provides a nice escape hatch for when things just don't work.
> What do you all think? 

I prefer the library API, myself.  I can imagine wanting the middleware
to do some kind of checking for non-OK response codes, although I don't
really like having the application set it:  raising exceptions is a Good
Thing, compared to making everybody above you have to handle the error
cases inline.

- --
Tres Seaver          +1 540-429-0999          [EMAIL PROTECTED]
Palladion Software   "Excellence by Design"    http://palladion.com
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

Repoze-dev mailing list

Reply via email to