how to access db from module

350 views
Skip to first unread message

Richard

unread,
Mar 9, 2010, 6:43:42 PM3/9/10
to web2py-users
I need to interact with the database from a module and I can't pass db
as an argument. (This is so I can use deferred on GAE:
http://groups.google.com/group/web2py/browse_thread/thread/d9092604580963f8)

Can this be done?

Richard

Russell

unread,
Mar 9, 2010, 7:01:37 PM3/9/10
to web2py-users
You might need to import the DAL?

From http://groups.google.com/group/web2py/browse_thread/thread/159b44bfbb634df2/83751f3fd6e51578

from gluon.sql import DAL, Field
db=DAL('sqlite://storage',folder='/path/to/databases/folder/')
db.define_table(....)
etc. etc.

On Mar 10, 12:43 pm, Richard <richar...@gmail.com> wrote:
> I need to interact with the database from a module and I can't pass db

> as an argument. (This is so I can use deferred on GAE:http://groups.google.com/group/web2py/browse_thread/thread/d909260458...)

Richard

unread,
Mar 9, 2010, 11:13:33 PM3/9/10
to web2py-users
ah I didn't know about this new feature - thanks.

However my tables rely on auth, which relies on being passed globals()
containing request, response, and session. Will I need to fake them?

On Mar 10, 11:01 am, Russell <russell.mcmur...@gmail.com> wrote:
> You might need to import the DAL?
>

> Fromhttp://groups.google.com/group/web2py/browse_thread/thread/159b44bfbb...

Russell

unread,
Mar 10, 2010, 4:51:21 PM3/10/10
to web2py-users
If you're on GAE then sessions are already in the database. I suppose
you could do the same with the other globals (or at least the parts
that auth uses). Why not pickle the stuff needed into the session
itself?
Reply all
Reply to author
Forward
0 new messages