[web2py] Re: using existing DB connection inside module/class

2012-02-28 Thread JaapP
Hi Anthony, Sorry for the delay.. The code as you show above looks indeed much the same as my code. I already discovered before that restarting Web2py server after module changes is a good idea. So this is not the solution for my problem. Your code works fine for me as well. After removing the db

[web2py] Re: using existing DB connection inside module/class

2012-02-25 Thread Anthony
Hmm, the following test code works for me without any db.commit: *In /controllers/default.py:* def index(): db.define_table('time', Field('time')) from mymodule import DbTest test = DbTest(db) return dict(results=db(db.time).select()) *In /views/default/index.html:* {{extend 'la

[web2py] Re: using existing DB connection inside module/class

2012-02-25 Thread JaapP
On Feb 24, 6:38 pm, Anthony wrote: > On Friday, February 24, 2012 12:24:03 PM UTC-5, JaapP wrote: > > > Hi Wikus, > > > Thanks a lot! > > Adding a db.commit() after an insert causes the database to be updated. > > The db.commit() shouldn't be needed. Can you show some code? > > Anthony This is

[web2py] Re: using existing DB connection inside module/class

2012-02-24 Thread Anthony
On Friday, February 24, 2012 12:24:03 PM UTC-5, JaapP wrote: > > Hi Wikus, > > Thanks a lot! > Adding a db.commit() after an insert causes the database to be updated. > The db.commit() shouldn't be needed. Can you show some code? Anthony

[web2py] Re: using existing DB connection inside module/class

2012-02-24 Thread JaapP
Hi Wikus, Thanks a lot! Adding a db.commit() after an insert causes the database to be updated. Bye, Jaap

[web2py] Re: using existing DB connection inside module/class

2012-02-24 Thread Anthony
On Friday, February 24, 2012 12:13:20 PM UTC-5, Wikus van de Merwe wrote: > > The code in controllers is wrapped in web2py with a try except clause that > automatically commits or rolls back the changes to db. I believe this is > not the case for modules and an explicit commit is needed there. Tr

[web2py] Re: using existing DB connection inside module/class

2012-02-24 Thread Wikus van de Merwe
The code in controllers is wrapped in web2py with a try except clause that automatically commits or rolls back the changes to db. I believe this is not the case for modules and an explicit commit is needed there. Try to add "db.commit" to your module code.

[web2py] Re: using existing DB connection inside module/class

2012-02-24 Thread Anthony
That should work fine. You don't have to use classes in modules. Anthony On Friday, February 24, 2012 11:45:13 AM UTC-5, Cliff wrote: > > Interesting. I wonder why my modules are working when I just pass the > db to the functions within them? > > On 1.99.2 I have something like this working.

[web2py] Re: using existing DB connection inside module/class

2012-02-24 Thread Cliff
Interesting. I wonder why my modules are working when I just pass the db to the functions within them? On 1.99.2 I have something like this working. mymodule.py contains no classes, just some functions. One looks like this: def myfunction(db, request, session, some_value): query = db[request