ok, that makes sense. And would I need to put import statements inside each function in my custom module? Or can I do something to get that module-level reference to request/response/session/etc working?
On Jul 11, 10:21 pm, mdipierro <[email protected]> wrote: > This is not a bad idea but there some rules to follow. > > request, response, session, cache, T are global objects in web2py so > if you import a function from a module, you have to pass those 5 > objects to the function (not all of them, only those you need). You > probably want to pass your database connection too. > > All the other web2py keywords can be imported from your modules as > needed. > > Massimo > > On Jul 11, 5:48 pm, Dan <[email protected]> wrote: > > > Hello- > > I want to re-use some data access routines in a few different > > controller files, so I would like to put them in a separate file in > > the /modules directory, and then import that file into the controller > > files that need them. However, I'm running into this error because I'm > > trying to use some web2py stuff in my module, like caching - and this > > is a conditional import that depends on accessing the request > > variable. > > > in /modules/my_module.py: > > if request.env.web2py_runtime_gae: # if running on Google App Engine > > from gluon.contrib.gae_memcache import MemcacheClient > > cache.ram=cache.disk=MemcacheClient(request) > > > error: > > name 'request' is not defined > > > Another way to put it is that I'm building an abstraction layer on top > > of web2py's DAL so that I can reuse my code. Is this possible? Or > > maybe a bad idea? > > > Dan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---

