I don't have much to say about the helper. But when talking about the
__init__.py proposal, I still think it is dangerous. The "pollution"
is not just about elegance or so, it could be about totally unusable.
Should namespace collision happen, the first app being visited
overwhelms the latter, the latter would certainly break.

Actually I had some thinking about this topic, I even tried to somehow
"unset" the sys.path after an app request had been served, therefore
no pollution. But I gave up eventually because I thought that could
not be multi thread safe.

Take your own risk.

On Apr28, 7:10pm, desfrenes <[email protected]> wrote:
> I see... but I don't think the helper would be that useful because
> imported modules may themselves import other modules, with the usual
> "import" keyword, not the helper.
>
> Perhaps applications could have the privilege to install libraries in
> contrib when they install ? Some post-install script could be
> executed. Of course then there would be a need of a post-deinstall
> script.
>
> I think the __init__.py polluting the sys.path is not that bad, at
> least it's simple, keeps up with the "self-contained" philosophy and
> the namespace collision risk should be low enough. Plus it lets the
> user install the libraries in site-packages if he wants to, without
> any change in the application code.
>
> Or maybe I just think too much and I should get that application up
> and running no matter how :-)
>
> On Apr 28, 10:54 am, Iceberg <[email protected]> wrote:
>
> > I just guess, perhaps that would pollute the sys.path. Imagine this
> > case, app_one and app_two both have a homebred module named "modules/
> > mylib.py", you can not know which one is actually called when using
> > just "import mylib".
>
> > Searching from this maillist, I found some post relevant to this topic
> > like this. Don't know whether that helper is finally accepted. Massimo
> > might have something to 
> > say.http://groups.google.com/group/web2py/browse_frm/thread/f9e117f081cfa...
>
> > On Apr28, 4:09pm, desfrenes <[email protected]> wrote:
>
> > > Hello !
>
> > > Because I needed mutagen in a project, I added this to the __init__.py
> > > of my application:
>
> > > import sys, os
> > > # add modules dir to sys.path
> > > sys.path.append( os.path.abspath(request.folder + 'modules/'))
>
> > > It works like a charm but why isn't "modules" already in sys.path
> > > since its purpose is to hold 3rd party modules that may be imported
> > > later ?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to