Hi, usefull response, 
but in function defined in test.py variables as session, db, request (and 
other function defined in default.py) are not visible. 
Is it normal or there's a way to make they somehow global?
Or the only way is to past as argument session, db, request? 
And for call funtions defined in default.py?

Thanks!
Fabio

Il giorno venerdì 4 novembre 2016 05:45:55 UTC+1, 黄祥 ha scritto:
>
> i think you can pass the parameter to the modules
> *e.g.*
> *controllers/default.py*
> def test():
> table = db.test
> return test.grid_0(table)
>
> *modules/test.py*
> from gluon import *
>
> def grid_0(table):
> grid = SQLFORM.grid(table)
> return locals()
>
> another way is access the dal directly from modules with current
> *e.g.*
> *controllers/default.py*
> def test():
> time_stamp = request.now
> client_ip = request.client
> user_id = auth.user_id
> origin = '%s/%s' % (request.controller, request.function)
> description = 'test'
> return test.insert_table_event(time_stamp, client_ip, user_id, origin, 
> description)
>
> *modules/test.py*
> from gluon import *
>
> def insert_table_event(time_stamp, client_ip, user_id, origin, 
> description):
> current.db.auth_event.insert(time_stamp = time_stamp, 
> client_ip = client_ip, 
> user_id = user_id, 
> origin = origin, 
> description = description)
> current.db.commit()
>
> thanks and best regards,
> stifan
>

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