#1077: trapping exceptions raised inside SA's run_with_transaction
-------------------------------------------+--------------------------------
Reporter: [EMAIL PROTECTED] | Owner: anonymous
Type: defect | Status: closed
Priority: high | Milestone: 1.0
Component: TurboGears | Version:
Severity: critical | Resolution: fixed
Keywords: sqlalchemy exception trapping |
-------------------------------------------+--------------------------------
Changes (by alberto):
* status: new => closed
* resolution: => fixed
Comment:
I've committed at [1769] a possible implementation for this using TG's
errorhandling. You can now define a function to trap arbitrary exceptions
which can occur inside SA's run_with_transaction (or any other controller
method as errorhandling has always allowed).
Usage example:
{{{
#!py
import errorhandling
@errorhandling.dispatch_error.when("isinstance(tg_exceptions,
IntegrityError)")
def handle_IE(controller, tg_source, tg_errors, tg_exceptions, *args,
**kw):
log.debug("An IntegrityError (%s) ocurred in method %r of controller
%r" %
tg_exceptions, tg_source, controller)
turbogears.flash("An integrity error ocurred")
#XXX: I'm not sure the later will work (tg_source *might* not be
decorated by expose)...
# My intention is to re-call the controller method that caused the
exception.
return tg_source(*args, **kw)
}}}
Alberto
--
Ticket URL: <http://trac.turbogears.org/turbogears/ticket/1077>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears Tickets" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears-tickets
-~----------~----~----~----~------~----~------~--~---