[Tutor] Exception and sys.exit() in a cgi script

Paulino paulino1 at sapo.pt
Sun Oct 15 19:44:09 CEST 2006


Thank you,

Yes I have other scripts working fine.

The OS is WXP and the server is the python's CGIHTTPserver (for an intranet use only)


---------
Hi Paulino,

>/ This is a peace of a CGI script i have.
/>/ 
/>/ 1 import cgi
/>/ 2 form=cgi.FieldStorage()
/>/ 3 try :
/>/ 4     ano=form["ano"].value
/>/ 5     conta=form["conta"].value
/>/ 6 except KeyError :
/>/ 7     print '<html><br><br><body><p>Please enter values in the
/>/ fields</p></body></html> '
/>/ 8     sys.exit(0)
/>/ 
/>/ 
/>/ When the excption occurs, no message is shown on the browser.
/
Can you tell us a bit more about the set up?
What OS? What web server? 

Can you get any other python CGI scripts running correctly?

>/ If I run the script with IDLE, the message is printed and then the
/>/ script exits.
/
The IDE environment is very different to a web server environment.

You should only treat IDLE as a first approximation when 
developing Web scripts. You can use the OS prompt for a slightly 
better approximation provided you set some environment variables 
first, but ultimately you need to test on the web server you will 
be using.

Alan G.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20061015/c8196e68/attachment.htm 


More information about the Tutor mailing list