On Friday, November 4, 2016 at 11:09:57 AM UTC-4, Fabio Ceccarani wrote:
>
> 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?
>

You have two options. First, you can simply pass any web2py API or global 
objects as arguments to functions or class constructors in your module. 
Second, you can import the "current" object in your module. It includes the 
request, response, session, cache, and T objects, and you can add your own 
objects to it (such as db). This is discussed here: 
http://web2py.com/books/default/chapter/29/04/the-core#Accessing-the-API-from-Python-modules

Anthony

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