good call, i updated the cookbook page, and just used: except web.HTTPError:
which is the parent class of the web.py Exceptions. -b On Tue, Feb 10, 2009 at 1:28 PM, andrei <[email protected]> wrote: > > I did the same workaround. > But still i wonder if its correct, or maybe web.Redirect needs to be > raised further like this: > > def load_sqla(handler): > web.ctx.orm = scoped_session(sessionmaker(bind=engine)) > try: > return handler() > except web.Redirect: > web.ctx.orm.commit() > raise > except: > web.ctx.orm.rollback() > raise > finally: > web.ctx.orm.commit() > > > On Feb 10, 11:30 pm, Brent Pedersen <[email protected]> wrote: >> hi, >> add a clause toi except for web.redirect: >> like below. >> though i dont know from memory the exact Exception you have to catch, >> but you get the idea. >> -b >> >> On Tue, Feb 10, 2009 at 12:28 PM, andrei <[email protected]> wrote: >> >> > in this pagehttp://webpy.org/cookbook/sqlalchemy >> >> > def load_sqla(handler): >> > web.ctx.orm = scoped_session(sessionmaker(bind=engine)) >> > try: >> > return handler() >> >> except web.Redirect >> pass> except: >> > web.ctx.orm.rollback() >> >> raise >> >> > finally: >> > web.ctx.orm.commit() >> >> > But web.redirect is an exception, so this code will do >> > web.ctx.orm.rollback() on every redirect. What if i want to redirect >> > after i post some data to create a new entry - it won't be saved in >> > the database. >> >> > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web.py" 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/webpy?hl=en -~----------~----~----~----~------~----~------~--~---
