Introduction
eric3 is an integrated development environment for the Python programming language. It can be used to debug code that is run by the mod_python module for the Apache web server. This document assumes mod_python is installed and Apache is configured to use it; please see the installation chapter of the mod_python manual for information on how to install it.
Since eric3's debugger support is single threaded, only one http request can be debugged at a time. A new debugging session is created for each request and the session is ended when the request processing ends. This is true of requests processed by a single Python module and it is true of requests processed by multiple Python modules in the same Apache process and its child processes. It is recommended that only one person debug mod_python based modules per Apache instance. Further on it is recommended to restart the Apache server after a debugging run because sometimes the socket connection to the IDE hangs on a later run. If you see a message in the „stdout“-window telling that a passive debugging connection was received, but nothing more happens, the socket connection is blocked and it is time to restart the Apache.
Quick Start
Copy eric3dbgstub_noqt.py from the eric3 installation directory into either the directory the module is in or another directory in the Python path used by the module as eric3dbgstub.py.
Insert import eric3dbgstub at the top of the module imported by the mod_python core.
Insert if eric3dbgstub.debugger is not None: eric3dbgstub.debugger.startDebugger(<filename>) at the top of each function that is called by the mod_python core (i.e. handler).
Enable passive listening in eric3 by choosing Settings -> Preferences -> Debugger -> Passive Debugger Enabled. Usuallay the port setting can be left unchanged. The eric3 IDE needs to be restarted for this preference to take effect.
Restart Apache and load a the URL to the Python script to trigger the module's execution.
If everything works ok, eric3 will show the file given in the startDebugger call above in an editor and highlight the statement after this call.
Now use the debugging commands to step through your script.
After finishing the debugging run restart the Apache server to have a clean next run. Otherwise it is possible, that the socket connection to the IDE may hang on successive runs.
Example
from mod_python import apache import eric3dbgstub def handler(req): if eric3dbgstub.debugger is not None: eric3dbgstub.debugger.startDebugger('/Path/To/modpython_dbg.py') req.content_type = "text/plain" req.send_http_header() req.write("Hello World!\n") return apache.OK