Mike Hansen Mike.Hansen at atmel.comMon Oct 16 18:43:29 CEST 2006 > 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. > > If I run the script with IDLE, the message is printed and then the > script exits. > > What's wrong here? > > > > _______________________________________________ > Tutor maillist - Tutor at python.org > http://mail.python.org/mailman/listinfo/tutor >I'm catching up on the weekend's tutor messages. import cgitb; cgitb.enable() That spits errors to the web page which is great for debugging cgi scripts. I think you need print "Content-Type: text/html\n\n" http://docs.python.org/lib/cgi-intro.html http://docs.python.org/lib/node560.html Mike Thats not the point (sorry). when all the values are provided in the form (no excetion is raised) it runs as expected! The point is when one of the values "ano", "conta" is missing in the form, I want the error message to be shown on the browser, and the script to stop running. When there is an exception, the script actually stops running, but no message is sent to the browser. |
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor