Home » Support » Index of All Documentation » How-Tos » How-Tos for Web Development »
3.0. Using Wing IDE with Turbogears
Wing IDE is an integrated development environment for the Python programming language. Wing can be used to speed up the process of writing and debugging code that is written for Turbogears, a powerful web development system.
In order to debug Turbogears applications, you will need Wing 3.0 or later, since earlier versions did not support multi-threaded debugging.
Installing Turbogears
The Turbogears website provides complete instructions for installing Turbogears. The procedure varies slightly by OS.
Configuring Turbogears to use Wing
This section assumes your Turbogears project is called wingtest. If not, substitute your project name in the following instructions.
- Go into the Turbogears instance directory wingtest and run Wing
- Add your directory to the project and save it as wingtest.wpr
- Open start-wingtest.py in Wing and set it as main debug file from the Debug menu
-
Edit start-wingtest.py and add the following before the server is started towards the end of the script:
import os if os.environ.has_key('WINGDB_ACTIVE'): cherrypy.config.update({'autoreload.on': False})This is needed to prevent creation of a sub-process controlled by the auto-restarter, which breaks debugging since Wing's debugger will not be running in the sub-process. If you omit this step, the symptom will be failure to stop on any breakpoints in your Turbogears application.
- Set a breakpoint on the return line of Root.index() in your controllers.py or somewhere else you know will be reached on a page load
- Start debugging in Wing from the toolbar or debug icon
- Bring up the Debug I/O tool in Wing and wait until the server output shows that it has started
- Load http://localhost:8080/ or the page you want to debug in a browser
- Wing should stop on your breakpoint
Notes
Some packages installed by Turbogears are not in unpacked eggs so the debugger cannot show the source code. This can be fixed by unpacking the *.egg files that are zip files so that they are replaced with directories of the same name that contain the contents of the zip files. For example, on Linux:
mkdir tmp mv cElementTree-1.0.5_20051216-py2.4-linux-i686.egg tmp cd tmp unzip cElementTree-1.0.5_20051216-py2.4-linux-i686.egg cd .. mv tmp cElementTree-1.0.5_20051216-py2.4-linux-i686.egg
Turbogears will install itself into whichever instance of Python runs the installer script, and only certain versions of Python work with a given version of Turbogears.
If you want to avoid adding Turbogears to an install of Python that you are using for other purposes, you can install Python to a new location and dedicate that instance to Turbogears. On Linux, this can be done as follows (assuming you create /your/path/to/turbogears as the place to install):
- In a Python source dist do:
./configure --prefix=/your/path/to/turbogears make make install
- Download tgsetup.py from the Turbogears website
- Edit tgsetup.py and change the one occurence of /usr/local/bin to /your/path/to/turbogears/bin
- Run /your/path/to/turbogears/bin/python tgsetup.py
- Change to /your/path/to/turbogears
- Run bin/tgadmin quickstart
- Enter project name wingtest and defaults for the other options
Similar steps should work on Windows and OS X.
Related Documents
Wing IDE provides many other options and tools. For more information:
- Wing IDE Reference Manual, which describes Wing IDE in detail.
- Turbogears home page, which provides links to documentation.
- Wing IDE Quickstart Guide which contains additional basic information about getting started with Wing IDE.
| « 3. How-Tos for Web Development | Table of Contents | 3.1. Using Wing IDE with Django » |
