What do you know... i found this in Stackoverflow, wich covers my question:
" ... In any multi-threaded Python program (and not only Python) you should not use os.chdir and you should not change sys.path when you have more than one thread running. It is not safe because it affects other threads. Moreover you should not sys.path.append() in a loop because it may explode. All web frameworks are multi-threaded and requests are executed in a loop. Some web frameworks do not allow you to install/un-install applications without restarting the web server and therefore IF os.chdir/sys.path.append are only executed at startup then there is no problem. In web2py we want to be able to install/uninstall applications without restarting the web server. We want apps to be very dynamical (for example define models based on information provided with the http request). We want each app to have its own models folder and we want complete separation between apps so that if two apps need to different versions of the same module, they do not conflict with each other, so we provide APIs to do so (request.folder, local_import). You can still use the normal os.chdir and sys.path.append but you should do it outside threads (and this is not a web2py specific issue). You can use import anywhere you like as you would in any other Python program. I strongly suggest moving this discussion to the web2py mailing list. ..." On Dec 2, 8:30 am, Alan Etkin <[email protected]> wrote: > The symbolic link approach seems to me to be more interesting than > modifying web2py.py, but i do not see why the sys.path.append thing at > application code is not recomended. I'll have to search on that topic. > > Thanks again for the support > > On Dec 2, 2:04 am, Massimo Di Pierro <[email protected]> > wrote: > > > you can create symbolic link to the web2py/site-packages folder or you > > can add a sys.path.append to web2py.py > > > On Dec 1, 9:14 pm, Alan Etkin <[email protected]> wrote: > > > > The required modules are stored outside the web2py folder because they > > > are shared by a non web2py app. So i cannot import them with that > > > method. I know i could just copy them into the app's modules folder > > > and that would be it, But i do not want to duplicate files. > > > > On Dec 1, 11:19 am, Anthony <[email protected]> wrote: > > > > > On Thursday, December 1, 2011 8:58:03 AM UTC-5, Alan Etkin wrote: > > > > > > >Instead making local_import("model") for a model stored at > > > > > >myweb2pyapp/ > > > > > >models/model.py, i need to make the same statement for a model stored > > > > > >at ~/another/path/module.py > > > > > > I meant import modules, sorry for the mistake. > > > > > > So to import a module from another path i could do: > > > > > > from gluon.custom_import import track_changes > > > > > track_changes(True) > > > > > sys.path.append("another/path") > > > > > I don't think manipulating sys.path from your app code is recommended. > > > > Is > > > > the module in the modules folder of another app? If so, just do: > > > > > from applications.appname.modules import mymodule > > > > > Anthony

