If this is in the context of an HTTP request, then web2py automatically 
handles the commit, so calling db.commit() is unnecessary. If the 
transaction is failing to commit, that means that your code is throwing an 
exception sometime *after* the confirmation email gets sent to the user 
(which seems unlikely given that that is the last line of the controller -- 
though the problem could be in the view). Were there any error tickets 
associated with the cases where the database update failed?

Anyway, be careful calling db.commit(). When an exception occurs, any 
database operations are automatically rolled back, which is usually what 
you want. If you call db.commit() in the middle of a request, any database 
operations up to that point will be committed, regardless of any subsequent 
exceptions encountered in the code.

One option to consider is to use the scheduler to schedule the email to be 
sent to the user after the request has been processed. The email task could 
first confirm the database update and then send the email only in case the 
confirmation was successful.

Anthony

On Tuesday, June 2, 2015 at 7:43:04 AM UTC-4, peter wrote:
>
> Yes Thanks Dmitry
>  
> Maybe that is the problem. I always forget about commit().
>
> I will add this in. 
>
> It will take me a while to know if it is the solution as the problem only 
> occurs every few months. 
>
> If I commit() does not sort it I will report back to the group eventually!
>
> Peter
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to