0% found this document useful (0 votes)
3 views1 page

Debugging mod_python with eric5

Eric5 is an IDE for Python that can debug code running via the mod_python module in Apache. To enable debugging, the mod_python installation must be patched to use Eric5's debugger instead of Pdb. Then passive listening must be enabled in Eric5 and a .htaccess file added to direct requests to connect to the IDE on load. When a URL is loaded, Eric5 will highlight the file and statement after the debugger is initialized.

Uploaded by

houstonrckts
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Debugging mod_python with eric5

Eric5 is an IDE for Python that can debug code running via the mod_python module in Apache. To enable debugging, the mod_python installation must be patched to use Eric5's debugger instead of Pdb. Then passive listening must be enabled in Eric5 and a .htaccess file added to direct requests to connect to the IDE on load. When a URL is loaded, Eric5 will highlight the file and statement after the debugger is initialized.

Uploaded by

houstonrckts
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Introduction

eric5 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 eric5'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 for requests processed by a single Python module and it is true for 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. Before you are able to use eric5 to debug mod_python modules you have to patch the mod_python installation. In order to do this, simply run the script patch_modpython.py contained in the eric5 distribution. This changes the file [Link] of mod_python to use the eric5 debugger instead of Pdb.

Quick Start

Enable passive listening in eric5 by choosing Settings -> Preferences -> Debugger -> General -> Passive Debugger Enabled. Usually the port setting can be left unchanged. The eric5 IDE needs to be restarted for this preference to take effect. Ensure you have a .htaccess file in the directory containing the module to be debugged. The .htaccess file should have a line containing PythonEnablePdb On. This will make the module connect to the eric5 IDE the next time the relevant URL is loaded in a browser. Add the line [Link]('/Path/To/Your/[Link]') right after the line importing [Link]. Load the URL to the Python script to trigger the module's execution. If everything works ok, eric5 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.

Example
.htaccess
AddHandler python-program .py PythonHandler modpython_dbg PythonDebug On PythonEnablePdb On

modpython_dbg.py
from mod_python import apache [Link]('/Path/To/modpython_dbg.py') def handler(req): req.content_type = "text/plain" req.send_http_header() [Link]("Hello World!\n") return [Link]

You might also like