Importing modules for cgi's

Orna Berlinsky orna27 at netvision.net.il
Thu Dec 20 01:36:55 EST 2001


Hi
I'm not so sure I understand what is the problem , but some weeks ago , as a
python novice I encountered similar problems (cgi etc.) .
This is the solution that was best suited to me :
Shell script that updates the PROXY and calls the python script :

#!/bin/sh

echo "Content-Type: text/html"
echo ""

export QUERY_STRING
http_proxy="http://aaa.bbb.ccc.dd.ee:8080"
export http_proxy
/users/my_cgi_path.cgi >&2 /dev/null &



and the python  script :

#!/usr/local/bin/python

"""Test my interface"""
import string , sys , cgi
sys.path.insert(0 , "my_path/python")
import myModuls


def go():
# have the cgi module parse the data for you...
form = cgi.FieldStorage()
# get the values of the fields
# run the python program


if __name__=="__main__":
go()



I hope my answer assist  you .

Good luck

Amit


----- Original Message -----
From: "Daniel" <dlNONNSPAMrubin at yahoo.com>
Newsgroups: comp.lang.python
To: <python-list at python.org>
Sent: Thursday, December 20, 2001 8:17 AM
Subject: Importing modules for cgi's


> Hi,
> I installed a database api module in python and added the path to my
> PYTHONPATH. In order for my cgi to work, though, I have to invoke my cgi
> from a shell script that first sets the PYTHONPATH so the module will be
> foud when the cgi runs. Is there a simpler way? I'd prefer not having to
> have the shell script. Is there a way for python to always know about my
> module without using PYTHONPATH?
>
> Another thing I tried that doesn't work is modifying sys.path at the
> start of the cgi script. It seems that this has to be set (via the shell
> script) before the cgi script starts.
>
> Thanks,
> Daniel
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>






More information about the Python-list mailing list