[mod_python] i beg the developers to make mod_python can be importin python command line.

Graham Dumpleton grahamd at dscpl.com.au
Tue Aug 15 01:14:31 EDT 2006

guo tie wrote ..
> hi,
>    All
>    These days i was work with mod_python, i found it is difficult to debug
> it , if you can made it be debuged in python command line mode ,
> i think it is a great thing

The closest you will get is to enable the 'PythonEnablePdb' option. See:


Ie., in your Apache configuration pertinent to where your handlers are have:

  PythonEnablePdb On

You then need to run Apache 'httpd' explicitly with the '-DONE_PROCESS'

  /usr/local/apache-2.0/bin/httpd -DONE_PROCESS

This runs Apache in single process mode.

Because Apache will try and use its regular listener port, you will need to
have shutdown your regular Apache instance first to do this.

With this option on, when a request comes in that triggers your request,
you will be thrown into a Python debugger environment. You can then
interact with your running request handler. For example:

~ grahamd$ /usr/local/apache-2.0/bin/httpd -DONE_PROCESS
> /Users/grahamd/public_html/filters/handlers.py(24)handler()
-> req.add_handler('PythonHandler', handler1)
-> result = object(arg)
> /Users/grahamd/public_html/filters/handlers.py(24)handler()
-> req.add_handler('PythonHandler', handler1)

print req.filename

print req.get_options()
{'mod_python.future.importer': 'testing'}

For details on the Python debugger and what it can do, see:


The only other option is to do what some users do, which is to construct
a mini framework which fakes up a request object which emulates the
minimum of what they required for their code to run. This allows them
to do some testing from the command line or using automated test scripts.

Hope this helps.


More information about the Mod_python mailing list