Is the 'request' error in mymodule.py? Note, you can't access the 'request' object in modules. You have to use current.request -- see http://web2py.com/book/default/chapter/04#Accessing-the-API-from-Python-modules.
Perhaps you're not getting an error when the import is in a function simply because the function hasn't been called (and therefore the import hasn't been attempted). Anthony On Friday, December 16, 2011 11:56:59 AM UTC-5, nekrox wrote: > > If i do > > default.py > > def index(): > import mymodule > > Its ok > > > But if i do > > default.py > > import mymodule > > def index(): > some code here > > > Its show an error where the error say > > NameError: name 'request' is not defined > > I dont import the module in each function, i want import only one time. > > 2011/12/16 Anthony <abas...@gmail.com> > >> Can you give an example? >> >> >> On Friday, December 16, 2011 11:43:00 AM UTC-5, nekrox wrote: >>> >>> >>> Each time when i try import a module out of a function python show a >>> error saying they would not find request. >>> >>> I have to necessarily import all modules inside of a function? >>> >>> -- >>> Alvaro Lizama Molina - http://alvarolizama.net >>> >> > > > -- > Alvaro Lizama Molina - http://alvarolizama.net >