local_import should work, but you should now use regular import statements instead. If you want your modules reloaded automatically, do the following: from gluon.custom_import import track_changes track_changes() That will reload your modules, but only when they change (which is an improvement over local_import, which will reload whether or not there are changes). Note, I believe the above will affect all applications. To turn off reloading, do: track_changes(track=False) And to test whether changes are currently being tracked: from gluon.custom_import import track_changes, is_tracking_changes if not is_tracking_changes(): track_changes() Anthony
On Friday, July 8, 2011 3:06:07 PM UTC-4, Jim S wrote: > Hi > > I have a utility module that I use regularly where I put some of my > application-specific helper functions. What is the proper way to import > this to make it available in my controllers and views? > > I've tried the local_import in db.py but have seen references on this list > that recommend against using that. This method had the reload=True option > that allowed me to make changes to my utility module and not have to restart > the web2py server to make the changes visible. > > If I recall correctly (and I certainly could be wrong), the preferred > method is to now use import. But, using this method I have to restart > web2py every time I make a change so I can see the results. > > Can someone please tell me how I can import a module and have it reload > automatically like local_import('module', reload=True) does? Or, should I > still be using local_import when I want reloading to occur? > > Thanks > > -Jim > >