[mod_python] conditions for a 404

David Bear David.Bear at asu.edu
Thu May 25 17:49:09 EDT 2006


On Thu, May 25, 2006 at 08:03:46PM +0200, Nicolas Lehuen wrote:
> Hi David,
> 
> First of all, you may want to read your Apache error log to get more
> information. In some cases, for security reasons, the user gets a
> simple 404 error whereas there is a more precise error message in the
> log.

This was the first place I looked. The only message in the error_log
is:

[Thu May 25 12:34:09 2006] [notice] mod_python: (Re)importing module
'tddb' with path set to '['/work/servers/www/htdocs/test']'
[Thu May 25 12:34:10 2006] [notice] mod_python: (Re)importing module
'tddb' with path set to '['/work/servers/www/htdocs/test']'
[Thu May 25 12:34:10 2006] [notice] mod_python: (Re)importing module
'tddb' with path set to '['/work/servers/www/htdocs/test']'
[Thu May 25 14:09:49 2006] [notice] mod_python: (Re)importing module
'mod_python.publisher'
[Thu May 25 14:09:49 2006] [notice] mod_python: (Re)importing module
'tddb' with path set to '['/work/servers/www/htdocs/test']'
[Thu May 25 14:09:49 2006] [notice] mod_python: (Re)importing module
'index' with path set to '['/work/servers/www/htdocs/test']'


> If you cannot read the error log, you can try switching on the
> PythonDebug configuration directive to get more detailled error
> messages on the client side. Don't forget to remove it when launching

I have debug on in the directive file:

---------
cat .htaccess
 AddHandler python-program .py
 PythonHandler mod_python.publisher
 PythonDebug On
------------



> your site on a production server, though, because those error messages
> usually contain stack trace, which gives a little bit more data to a
> would-be hacker than you would like.

thanks. good advice. this would be a good think to document in a
modpython best practices.

> 
> BTW, even if this should not lead to the problem you observe, you are
> using the handler's style of coding instead of the publisher style.
> Published functions or methods do not return apache.OK, they simply
> return a string that needs to be returned to the client, or None if
> req.write() is used to send content to the client. Also, you do not
> need to use req.send_http_headers().

ok. this wasn't clear. I've updated the code to be

=====================================
from mod_python import session

page1 = '''
<html>
 <head>
  <title>page 1 </title>
 </head>
 <body>
  this is page 1 boo
 </body>
</html> 
'''

def index(req):
  return page1

def info(req):
  res = []
  thereq = dir(req)
  for i in thereq:
    res.append(i)
  return("%s " % res)
  
==================================

and I still get a 404 error. It would be nice if there were a way to
start a python interpreter, and import the module just to see if there
were some other reason for the error -- syntax, indentation...
  

> 
> All this is assuming that you are using the latest mod_python release,
> namely the 3.2.8 one. If you don't then I strongly suggest you
> upgrade, because you've missed more than one year of bugfixes.
>

sorry, I should have included that. I'm using modpython 3.1.x and
apache 2.0.53 all packaged by suse. Since this is suse 9.3 I'm a
little hesitant to upgrade the modpython for fear of breaking
something else suse might have as a dependancy.

-- 
David Bear
phone: 	480-965-8257
fax: 	480-965-9189
College of Public Programs/ASU
Wilson Hall 232
Tempe, AZ 85287-0803
 "Beware the IP portfolio, everyone will be suspect of trespassing"


More information about the Mod_python mailing list