Can't you just call rollback() on the transaction... On 3/21/07, Ram Yalamanchili <[EMAIL PROTECTED]> wrote: > > But what if you had a def save() routine which on failure has to > redirect the sender to some other page (possibly the refered page)? In > this case you want the transaction to get backed out.. but if you do a > redirect() it will not get backed out as you can't raise an exception. > > How is this case dealt with? > > thanks, > Ram > > On 3/20/07, Mark Ramm <[EMAIL PROTECTED]> wrote: > > > > If you want to handle transactions on your own, you can prepend > > notrans_ to the sqlobject dburi in the config file, like this: > > > > sqlobject.dburi="notrans_mysql://username:[EMAIL > > PROTECTED]:port/databasename" > > > > On 3/20/07, Jesse James <[EMAIL PROTECTED]> wrote: > > > > > > I have a controller method that looks something like this: > > > > > > @tg.expose() > > > def foo(self, etc..): > > > result="ok" > > > trans = session.create_transaction() > > > try: > > > create some records, etc... > > > except: > > > result="problem..." > > > if(result=="ok"): > > > try: > > > do some file ops. > > > except: > > > result="problem..." > > > if(result=="ok"): > > > trans.commit() > > > else: > > > trans.rollback() > > > return result > > > > > > I'm running into the problem discussed here: > > > http://groups.google.com/group/sqlalchemy/browse_thread/thread/4236f9... > > > > > > I'm getting an exception that indicates that the transaction is > > > inactive if either try block raises an exception. > > > > > > Apparently, the TG @expose decorator wraps the session in a > > > transaction (sa_wrt) within which the controller method runs. When > > > the controller raises an exception and rolls back, the commit() that > > > happens after the controller code block is trying to commit an already > > > rolled back transaction. > > > > > > There was a fairly detailed and lengthy discussion in this group > > > recently involving the use of a 'special' decorator for methods that > > > need to have explicit transaction control, like mine above. > > > > > > Is this fixed in 1.01b? Can anyone point me to explicit documentation > > > or a simple example about how to do this? My site is going live today > > > and this would be highly appreciated. > > > > > > Thanks, > > > JJ > > > > > > > > > > > > > > > > > > > -- > > Mark Ramm-Christensen > > email: mark at compoundthinking dot com > > blog: www.compoundthinking.com/blog > > > > > > > > > > >
-- 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?hl=en -~----------~----~----~----~------~----~------~--~---

