sys.path.insert(0, '')
path = os.path.dirname(os.path.abspath(__file__))
if not path in sys.path:
sys.path.append(path)
sys.path.append(os.path.join(path,'site-packages'))
os.chdir(path)
(fcgi alone doesn't do the chdir; bug?)
I think that site-packages will tend not to be in sys.path (except when running Rocket; that uses different logic), because Python automatically prepends the directory of the startup script to sys.path. So 'if' will never trigger, and we'll never append site-packages.
Also, it's not clear to me what sys.path.insert(0, '') is there for.
I will apply your patch tomorrow.
> sys.path.insert(0, '')
was added to make sure import always looks first in the folder where the importing function is located. This was necessary to avoid conflict with installed third party modules which may have the same name as web2py modules. It was a problem for simplejson for example.
Massimo
> --
> mail from:GoogleGroups "web2py-developers" mailing list
> make speech: web2py-d...@googlegroups.com
> unsubscribe: web2py-develop...@googlegroups.com
> details : http://groups.google.com/group/web2py-developers
> the project: http://code.google.com/p/web2py/
> official : http://www.web2py.com/
You ought to see if you can reproduce your ctrl-c crash first.
>
>> sys.path.insert(0, '')
>
> was added to make sure import always looks first in the folder where the importing function is located. This was necessary to avoid conflict with installed third party modules which may have the same name as web2py modules. It was a problem for simplejson for example.
I understand that part, more or less. But it ought to be redundant, since Python already inserts the directory of the starting script at the beginning of sys.path (which also means that site-packages won't be added, except with Rocket).
Also, the fcgi handler is missing the insert, as well as the chdir:
path = os.path.dirname(os.path.abspath(__file__))
if not path in sys.path:
sys.path.append(path)
sys.path.append(os.path.join(path,'site-packages'))
It seems to me that the insert "" is redundant, and the append site-packages is never happening (except for Rocket). And that fcgi is the odd man out.