Wing is a Python IDE that can be used to develop, test, and debug Python code that is run by the mod_python module for the Apache web server. Two versions of Wing are appropriate for use with this document: Wing Pro is the full-featured Python IDE for professional programmers, and Wing Personal is a free alternative with reduced feature set.

If you do not already have Wing installed, download it now.

This document describes how to configure Wing for mod_python. To get started using Wing as your Python IDE, please refer to the tutorial in Wing's Help menu or read the Quickstart Guide.

Introduction

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 Wing's debugger takes control of all threads in a process, only one http request can be debugged at a time. In the technique described below, a new debugging session is created for each request and the session is ended when the request processing ends. If a second request is made while one is being debugged, it will block until the first request completes. 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. As a result, it is recommended that only one person debug mod_python based modules per Apache instance and production servers should not be debugged.

Quick Start

Example

To debug the hello.py example from the Publisher chapter of the mod_python tutorial, modify the hello.py file so it contains the following code:

import wingdbstub

def say(req, what="NOTHING"):
  wingdbstub.Ensure()
  return "I am saying %s" % what

And set up the mod_python configuration directives for the directory that hello.py is in as follows:

AddHandler python-program .py
PythonHandler mod_python.publisher

Then set a breakpoint on the return "I am saying %s" % what line, make sure Wing is listening for a debug connection, and load http://[server]/[path]/hello.py in a web browser (substitute appropriate values for [server] and [path]). Wing should then stop at the breakpoint.