On Thu, Feb 9, 2012 at 11:45 AM, Anthony <[email protected]> wrote:
> from gluon import current
> current.db = db
>
I dont think that adding db to current will work properly, it can work in
SQLITE, but for sure will raise problems with another databases.
I realized that db needs to be instantiated inside a module or passed
explicitly as an arg, it is not possible to serialize it in to current. It
works in the first request, but not for the subsequents.
Another advice is that you never have to assign variables to current
outside functions and methods
Example.
*Module.py*
from gluon import current
> request = current.request
>
> def myfunction(db):
> if request.args....... # HERE BE THE DRAGONS!
>
To work you need to do
*Module.py*
from gluon import current
def myfunction(db):
request = current.request
if request.args.... # IT WORKS
It happens because if you assign outside the function, it will be evaluated
only at the first request, and for the subsequents, the request object will
always be the same.
--
Bruno Rocha
[http://rochacbruno.com.br]