Because requests are handled by threads, the way to do this may be to use the current object. Note that you should replace "processes" with "threads" in your question. Most web2py execution environments are multi-threaded not not-multiprocess.
You set your global variables in one of the code bodies executed at each request; example the default model db.py, and assign them to the current object. This is often done for passing to modules web2py global variables like DAL instances. Therefore the documentation in the book concentrates on solving this problem http://www.web2py.com/books/default/chapter/29/04/the-core#Accessing-the-API-from-Python-modules but the idea is extendable to all globals. Then in each *function* in a module, you retrieve them. Don't retrieve them in the lexical global scope of the module file (i.e. outside a function body) because that code is not run in the thread you are interested in (the thread in which your module function is running). On Wednesday, 3 December 2014 05:01:04 UTC+11, Alan Evangelista wrote: > > Most of my application code is running in Python modules in the modules > directory. In the modules directory, I have a few singletons which are > implemented as variables defined in the main body of a globals module. > However, it seems that web2py runs my modules and the controller in > different processes and controller is unable to see the globals defined in > the modules directory. I do not have this issue in other web frameworks > such as Django. How do you usually handle this problem? > -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.

