[mod_python] debuging modpython publisher issues

David Bear David.Bear at asu.edu
Fri Jun 2 15:06:32 EDT 2006

I'm getting really frustrated. I have a python program that works.
Then make modifications that should affect things -- then it breaks.

I've got to figure a better way of debugging.

Here's an example:

I have a python program:

def _return_psp(req, ad, tmpl="empty.pspml"):
    returns a psp template with all vars and whatever is in ad
    ad.setdefault('title', 'Empty Page')
    vars = {"ad": ad}
    return psp.PSP(req, tmpl, vars=vars)

def getDebug(req):
    returns values for debug and object introspection
    form = req.form
    info = []
    info.append('request uri %s ' % req.uri)
    info.append('req.connection.base_server: %s ' % req.connection.base_server)
    bodycontent = ''.join(info)
    return _return_psp(req, dict(body=bodycontent, title="Debug Page"), "empty.pspml")

# if __name__ == "__main__":
#    sys.exit(1)

I have a psp file called empty.pspml that looks like this:

""" psp  """
    title = ad['title']
except KeyError:
    title = "Key Error in AD"
    dbg = ad['body']
except KeyError:
    dbg = 'Didnt have debug Info'
   <%= title %>
<h1><%= title %></h1>
<%= dbg %>


Okay. It all works the way I expect. Calling the url

returns the results I expect.

Then I add a function like this:

def index(req):
     return _return_psp(req, dict(body="this is stupid", title="stupid

Now everything apache returns is a 404 (but the apache not found page
is NOT returned, ie the body content of the http response is empty)

Looking in my apache logs all I see is the modpython is reimported a

Fri Jun 02 11:51:21 2006] [notice] mod_python: (Re)importing module
[Fri Jun 02 11:51:21 2006] [notice] mod_python: (Re)importing module
'mypthon' with path set to '['/htdocs/mp']'

There's got to be a better way. I comment out all the import
statements the are modpython specific, and use a command line python
session to import the module -- it imports without errors. I was
thinking importing it would reveal any syntactic errors... 

Any other pointers on debug methods?

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