A module is a module. You can import stuff form the module but the
module will not see variables defined in the calling environment.
In the module you can defined a function that takes db as parameter,
import the funciton and call it with the db instance. You will have
the problem not just for db, but also for the other web2py global
objects.

Massimo

On May 4, 4:16 am, canna <[email protected]> wrote:
> hi all,
> I want to share a bunch of functions between controllers, so I moved
> them to a module called 'utilities' in the modules folder, and in the
> controller I import the module as suggested here in the forum:
>
> import applications.myapp.modules.utilities as util
> reload(util)
>
> the problem is, it's not working, I get an error:
>
> NameError: global name 'db' is not defined
>
> how can I get my 'utilities' file to recognize the global variable
> 'db'?

Reply via email to