Note

"The best solution for debugging Zope and Plone" -- Joel Burton, Member, Plone Team

Wing is a Python IDE that can be used to develop, test, and debug Python code written for Zope2 or Zope3. Wing provides auto-completion, call tips, and other features that help you write, navigate, and understand Zope code. Wing's debugger can be used to debug code in the context of the running Zope server, in response to page loads from a browser, and can work with Zope's code reloading features to achieve a very short edit/debug cycle.

Wing's code intelligence and debugging support work with Products, External Methods, file system-based Scripts and Zope itself. Wing is also useful for Zope-based frameworks like Plone (see Plone How-To).

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 Zope. To get started using Wing as your Python IDE, please refer to the tutorial in Wing's Help menu or read the Quickstart Guide.

Before Getting Started

Note: This guide is for Zope2 users. If you are using Zope3, please try z3wingdbg by Martijn Pieters or refer to Debugging Externally Launched Code in the users manual to set up Zope3 debugging manually.

Limitations: Wing cannot debug DTML, Page Templates, ZCML, or Python code that is not stored on the file system.

Security Warning: We advise against using the WingDBG product on production web servers. Any user connected to the Wing debugger will (unavoidably) have extensive access to files and data on the system.

Upgrading from earlier Wing versions

If you are upgrading from an older version of Wing and have previously used Wing with your Zope installation(s), you need to manually upgrade WingDBG in each Zope instance. Otherwise, debugging may fail.

The easiest way to do this is to go to the Zope Control Panel, click on Wing Debug Service, and then Remove the control panel. Then restart Zope. Next, go into your Wing project's Extension Tab, verify that you've got the Zope Instance Home set correctly, and press Apply. This will offer to re-install WingDBG with the latest version and will configure it to point to the new version of Wing.

Quick Start on a Single Host

To use Wing with Zope running on the same host as the IDE:

Starting the Debugger

Proceed to the Wing Debugger Service by navigating to the Control Panel, then selecting the 'Wing Debugging Service'. Click in the "Start" button. The Wing IDE status area should display "Debugger: Debug process running".

Note that you can configure WingDBG to start and connect to the IDE automatically when Zope is started from the Advanced configuration tab.

Problems? See the Trouble-Shooting Guide below.

Test Drive Wing

Once you've started the debugger successfully, here are some things to try:

Run to a Breakpoint -- Open up your Zope code in Wing and set a breakpoint on a line that will be reached as the result of a browser page load. Then load that page in your web browser using the port number displayed by the Zope Management Interface after you started the debugger. By default, this is 50080, so your URL would look something like this:

http://localhost:50080/Rest/Of/Usual/Url

Explore the Debugger Tools -- Take a look at these tools available from the Tools menu:

Continue the Page Load -- When done, select Start / Continue from the Debug menu or toolbar.

Try Pause -- From Wing, you can pause the Zope process by pressing the pause icon in the toolbar or using Pause from the Debug menu. This is a good way to interrupt a lengthy computation to see what's going on. When done between page loads, it pauses Zope in its network service code.

Other Features -- Notice that Wing's editor contains a source index and presents you with an auto-completer when you're editing source code. Control-click on a source symbol to jump to its point of definition (or use Goto Selected Symbol in the Source menu). Wing Pro also includes a Source Assistant and Source Browser. The Source Assistant will display context appropriate call tips and documentation. Bring up the Source Browser from the Tools menu to look at the module and class structure of your code.

Setting Up Auto-Refresh

When you edit and save Zope External Methods or Scripts, your changes will automatically be loaded into Zope with each new browser page load.

By default, Zope Products are not automatically reloaded, but it is possible to configure them to do so. This can make debugging much faster and easier.

Take the following steps to take advantage of this feature:

Limitations: Zope may not refresh code if you use import statements within functions or methods. Also, code that manages to retain references to old code objects after a refresh (for example, by holding the references in a C/C++ extension module) will not perform as expected.

If you do run into a case where auto-reload causes problems, you will need to restart Zope from the Zope Management Interface's Control Panel or from the command line. Note that pressing the Stop button in Wing only disconnects from the debug process and does not terminate Zope.

Alternative Approach to Reloading

The refresh.txt techique for module reloading is discouraged in the Plone community. Another option for reloading both Zope and Plone filesystem-based code is plone.reload available from pypi at http://pypi.python.org/pypi/plone.reload. plone.reload will allow you to reload Python code that has been changed since the last reload, and also give you the option to reload any zcml configuration changes.

If you are using buildout, add plone.reload to the eggs and zcml sections of your buildout.cfg and re-run buildout.

To use plone.reload, assuming Zope is running on your local machine at port 8080, log into the ZMI as a Manager user, then go to http://localhost:8080/@@reload on your Zope instance with a web browser (append @@reload to the Zope instance root, not your Plone site if you are using Plone).

Notes:

Setting up Remote Debugging

Configuring Wing for remote debugging can be complicated, so we recommend using X11 (Linux/Unix) or Remote Desktop (Windows) to run Wing on the same machine as Zope but display it remotely. When this is not possible, you can set up Wing to debug Zope running on another machine, as described below:

Trouble Shooting Guide

You can obtain additional verbose output from Wing and the debug process as follows:

For additional help, send these errors logs to support at wingware.com.