CGI and logging module

Peter Mott peter at monicol.co.uk
Fri Nov 19 04:00:00 EST 2004


Thanks for these responses all useful. I had completed a fairly large script 
which threw these unrecorded errors at me. Took ages to locate the soiurce 
of the problem. I should have used the try: except: round the import 
statement (I was using the 'import cgitb;cgitb.enable()' mantra but _after_ 
the impoprt statement :-( ).

As I said I am using Python on FreeBSD:

Python 2.3.4 (#2, Nov 14 2004, 18:06:48)
[GCC 2.95.4 20020320 [FreeBSD]] on freebsd4
Type "help", "copyright", "credits" or "license" for more information.
>>> import logging
>>>

and I imported loggng successfully. When I modify my script to the 
following:
===============
#!/usr/local/bin/python

try:
   import logging
except Exception, e:
   print "Content-type: text/html\n"
   print "<html><head><title></title></head><body><p>" + str(e) +"<p>"""
else:
   print "Content-type: text/html\n"
   print 
"<html><head><title></title></head><body><h1>OK</h1></body></html>"""

==============
It reports the error which is " No module named logging " .  Something is 
wrong here. Does anyone have any ideas?

Peter



"Peter Mott" <peter at monicol.co.uk> wrote in message 
news:419d0a70$0$221$bed64819 at news.gradwell.net...
>I am using:
>
> Python 2.3.4 (#2, Nov 14 2004, 18:06:48)
> [GCC 2.95.4 20020320 [FreeBSD]] on freebsd4
>
> with Apache/1.3.26. The following script causes an Internal Server Error 
> (with nothing in the Apache error logs AFAIK):
>
> #!/usr/local/bin/python
>
> import logging
>
> print "Content-type: text/html\n\n"
> print "<html><head><title></title></head><body><h1>OK</h1>"""
> print "</body></html>"
>
> The same script with the import statement commented out works as expected. 
> Has anyone encountered this? I have googled without success.
>
> Thanks
>
> Peter
> 





More information about the Python-list mailing list