On Friday, August 9, 2013 11:11:13 PM UTC+2, Joe Barnhart wrote:
>
> I need to preserve the database state by keeping the changes to the tables 
> in a consistent state.  If I insert a group of records, I need to make sure 
> they all succeed or fail.  I can't commit them one at a time in this case.
>
 
offtopic2-continued: web2py wraps every request is the exact same manner, 
in order to give you atomicity of all db operations in a request. If you 
just need those "special insert()s" to happen or not atomically, then you 
can totally use the try:except block, for as many insert()s as you like.

Every piece of DAL write operation between two commit()s or a commit() and 
a rollback() are atomical.

If instead you need to have 
try:
    piece of normal code
    try:
        "special insert handled by those functions"
    except:
        rollback only the special insert
    another piece of normal code
except:
    rollback both

then you're requiring nested transactions, that I anticipated would not 
work with the try:except block . Usually you can still get around placing 
commit()s and rollback()s in the correct places, but if you don't want to 
play with them your issue with savepoints can very well still be 
circumvented by a tailored insert.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to