What's written in the book is not worded well. Whenever database 
modifications happen within a web2py HTTP request/response cycle, there is 
no need to call db.commit(), no matter where the code is (it all gets 
executed by the web2y framework, with web2py calling db.commit() itself 
just before returning the response).

If you are running code outside of the context of an HTTP request (e.g., in 
a standalone script/module, a scheduled task, etc.), then you need to call 
db.commit(). So, for example, if you have defined a scheduler task in a 
model file, you must call db.commit() within that task even though it is in 
a model file (because when the task is executed, it will not be in the 
context of an HTTP request).

Anthony

On Thursday, June 16, 2016 at 6:56:42 AM UTC-4, Pierre wrote:
>
> Hi,
>
> w2p book says to issue *db.commit()* commands when DAL 
> insert/update/delete operations are located in a module(as opposed to being 
> located in a controller) but it seems to work fine even without these. what 
> is it really ? necessary , not necessary.......
>
>
>

-- 
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