On Jun 13, 12:58 pm, arorap <[EMAIL PROTECTED]> wrote: > Thanks for your reply. > > The reason I want to run it as CGI (even though mod_php is available > on my local computer
Why do you keep mentioning mod_php, surely you mean mod_python. > is that the target machine to which I will > finally be uploading my scripts runs CGI. > > cgihandler should work just like CGI. I wouldn't rely on it being exactly the same. The way it works uses a number of kludges. Also, the mod_python.cgihandler code in mod_python doesn't really get much attention from mod_python developers anymore and not sure if it was even specifically retested when mod_python 3.3 was released. > Any clue why the > cgi.FieldStorage()might not be working ? Have no idea why it doesn't work as works as written on MacOS X even when mod_python.cgihandler is used. You'll have to get someone else who has Windows to try it. You might be better off going to the mod_python mailing list to get help, or just use plain old CGI instead since using mod_python isn't really going to gain you much anyway. Graham > On Jun 12, 7:59 pm, Graham Dumpleton <[EMAIL PROTECTED]> > wrote: > > > On Jun 13, 1:17 am,arorap<[EMAIL PROTECTED]> wrote: > > > > I've mod_php installed with Apache 2.2. In one of my folders, I'm > > > using the cgihandler as the PythonHandler as my target host runs > > > python only as CGI. Here cgi.FieldStorage() doesn't seem to work. I > > > can see the form data in sys.stdin but cgi.FieldStorage() returns an > > > empty dictionary. Here's the code for the test script I am posting to > > > - > > > > -- > > > #!/usr/bin/python > > > > import os > > > import cgi > > > import sys > > > > print "Content Type: text/plain\n\n" > > > print "Hello CGI World !\n" > > > > for key in os.environ: > > > print key + "= " + os.environ[key] > > > > print cgi.FieldStorage() > > > > print sys.stdin.read() > > > -- > > > > And here's the output I see .. > > > > -- > > > Hello CGI World ! > > > > HTTP_REFERER=http://learnpython/form.htm > > > SERVER_SOFTWARE= Apache/2.2.4 (Win32)mod_python/3.3.1 Python/2.5.1 > > > SCRIPT_NAME= /mptest.py > > > SERVER_SIGNATURE= > > > REQUEST_METHOD= POST > > > SERVER_PROTOCOL= HTTP/1.1 > > > QUERY_STRING= abc=ayz > > > PATH= C:\Program Files\Internet Explorer;;C:\WINDOWS\system32;C: > > > \WINDOWS;C:\WINDOWS\System32\Wbem;q:\bin;m:\cm\clearcase\bin;M:\PERL\NT > > > \EXEC\BIN;m:\cm\clearcase\bin\nt;M:\Perl\NT\EXEC\BIN;m:\perl\nt\exec > > > \bin;m:\cm\clearcase\utils;q:\bin;m:\opus;m:\tvcs;C:\highc331\bin;C: > > > \Program Files\Rational\ClearCase\bin;C:\Program Files\Rational\common > > > CONTENT_LENGTH= 86 > > > HTTP_USER_AGENT= Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; > > > SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727) > > > HTTP_CONNECTION= Keep-Alive > > > SERVER_NAME= learnpython > > > REMOTE_ADDR= 127.0.0.1 > > > PATHEXT= .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH > > > SERVER_PORT= 80 > > > SERVER_ADDR= 127.0.0.1 > > > DOCUMENT_ROOT= D:/Projects/LearnPython/www > > > COMSPEC= C:\WINDOWS\system32\cmd.exe > > > SCRIPT_FILENAME= D:/Projects/LearnPython/www/mptest.py > > > SERVER_ADMIN= [EMAIL PROTECTED] > > > HTTP_HOST= learnpython > > > SystemRoot= C:\WINDOWS > > > HTTP_CACHE_CONTROL= no-cache > > > REQUEST_URI= /mptest.py?abc=ayz > > > HTTP_ACCEPT= */* > > > WINDIR= C:\WINDOWS > > > GATEWAY_INTERFACE= Python-CGI/1.1 > > > REMOTE_PORT= 1081 > > > HTTP_ACCEPT_LANGUAGE= en-us > > > CONTENT_TYPE= application/x-www-form-urlencoded > > > HTTP_ACCEPT_ENCODING= gzip, deflate > > > > FieldStorage(None, None, []) > > > > firstName=puneet&address=hawaii > > > -- > > > > I am posting to this script using a form with two text fields named > > > firstName and address. > > > > any clue where am I going wrong ? > > > You don't need mod_python/cgihandler to run CGI scripts. Rather than > > bring mod_python into the picture and confuse things, set up Apache to > > run your script as a traditional CGI script instead. > > > BTW, the fact that mod_python is loaded means that CGI scripts aren't > > the only way of using Python available to you as you seem to think. > > So, suggest you do some research as to what the differences are > > between CGI and mod_python. -- http://mail.python.org/mailman/listinfo/python-list