Yes. web2py automatically rollsback on any exception other than HTTP.
raising HTTP is not considered an error.

This is explained in the book. I agree it should be explained also in
the online docs.

Massimo

On Feb 2, 10:08 pm, Iceberg <iceb...@21cn.com> wrote:
> Hi Massimo,
>
> A further question for this topic.
>
> I remember one of the old topic in this forum group mentioned that, in
> every action we do not need an explicit db.commit() because web2py
> automatically does it when no exception is raised during the action.
>
> So I wonder whether web2py automatically does db.rollback() when any
> exception is raised inside an action? Or do we have to do it
> explicitly in a try...except... clause (but why)?
>
> Besides, in order to make people aware of that, perhaps the answer of
> this issue shall appear in built-in document, and/or appear as a doc
> string in applications/welcome/controller/default.py 's index()?
>
> On Feb 3, 5:29 am, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > db.rollback()
>
> > you can do this for example...
>
> > try: do your stuff
> > except: db.rollback()
>
> > On Feb 2, 3:22 pm, pedro <pedro...@gmail.com> wrote:
>
> > > Ok, I don't want to reinvent the wheel, in the book it says that the
> > > actions are wrapped in a transaction.. So my question is: what's the
> > > best/simplest/more recommended  way to rollback?
>
> > > I need to insert a few records per action or rollback in case one
> > > fails. Am I ok if i simply raise an exception on failure?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to