You can do a hub.commit in your try statement.  This should move the
error up in time.

If you want to turn automatic transactions off, and handle all the
transaction stuff yourself,  you can add notrans to the your database
URI as described in the config file.

--Mark

On 3/21/06, Roger Rohrbach <[EMAIL PROTECTED]> wrote:
>
> Can anyone enlighten me as to the TurboGears technique for trapping the
> attempt to create an object where an attribute specified as an
> alternateID is a duplicate?
>
> I can do this in the TG shell:
>
> try:
>     f = MyClass( name='Binky')
> except hub.getConnection().module.IntegrityError, e:
>     errMsg = e[1]
>
> but when I take this into my controller, I can no longer catch the
> exception.  TG catches it in the function run_with_transaction() in
> database.py, calls rollback_all(), then re-raises the exception.  But
> rollback_all() fails (it probably wasn't designed to handle constraint
> violations), and the exception never gets re-raised.
>
> I'm wondering if the undocumented @turbogears.exception_handler
> decorator would be useful here, but I can find no hint as to how it
> might be employed.
>
> Any help gratefully accepted.
>
>
>
>


--
Mark Ramm-Christensen
email: mark at compoundthinking dot com
blog: www.compoundthinking.com/blog

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to