Using Wing IDE with the Google App Engine


Home » Support » Index of All Documentation » How-Tos » How-Tos for Web Development »

Wing IDE is an integrated development environment that can be used to write, test, and debug Python code that is written for the Google App Engine. Wing provides auto-completion, call tips, a powerful debugger, and many other features that help you write, navigate, and understand Python code. Since Google App Engine will reload your code when you save it to disk, you can achieve a very fast edit/debug cycle without restarting the debug process.

For more information on Wing IDE see the product overview. If you do not already have Wing IDE installed, download a free trial now. To get started using Wing, refer to the tutorial in the Help menu in Wing and/or the Wing IDE Quickstart Guide.

In order to debug Google App Engine applications, you will need Wing 3.1 beta3 or later, since earlier versions were missing some important functionality.

Configuring the Environment

In order for Wing to be able to work with Google App Engine code, you will need to create a project in Wing and set the main debug file to the dev_appserver.py located in the top level of the Google SDK directory. This is done with the Set Current As Main Debug File item in the Debug menu or by right clicking on the file in the Project tool and selecting Set As Main Debug File.

Debugging Your Application

You can debug code running under the Google App Engine by selecting Start / Continue from the Debug menu (or use the run icon in the toolbar) and then specifying your application's directory as the run argument. For example, to run the guestbook demo that comes with the SDK, the run argument would be "${GOOGLE_APPENGINE_DIR}/demos/guestbook" where ${GOOGLE_APPENGINE_DIR} is replaced by the full pathname of the directory the SDK is installed in or an environment variable is set up with the pathname (or use ${WING:PROJECT_DIR} to base the path on the directory where the project file is located). The quotation marks are needed if the pathname contains a space.

Using a partial path for the application may also be possible if the Initial Directory is also set in under the Debug tab.

Once the debugger is started, requests may be made with a web browser and breakpoints may be set in any Python file. For example, to break when the main page of the guestbook demo is generated, set a breakpoint in the method Mainpage.get in guestbook.py. You may edit the Python code for an application while the App Engine is running, and then reload to see the changes. In most cases, there is no need to start the debug process after edits.

Note that the Debugger / Exceptions / Report Exceptions preference should be set to When Printed (the default) when working with Google App Engine or Wing will report some additional exceptions that are handled internally when running Google App Engine outside of the debugger.

Windows users will probably want to set the TZ environment variable to UTC via the environment field in Project Properties to work around problems with setting os.environ['TZ'] while a process is running (see Issues on Microsoft Windows for details about the Windows runtime bug)

Improving Auto-Completion and Goto-Definition

Wing can't parse the sys.path hackery in more recent versions of Google App Engine so it may fail to find some modules for auto-completion, goto-definition and other features. To work around this, set a breakpoint in fix_sys_path in dev_appserver.py and start debugging. Then, in the Debug Probe tool (in Wing Pro only) type the following:

os.pathsep.join(EXTRA_PATHS)

Copy this to the clipboard and open up the file properties for dev_appserver.py by right-clicking on the file. Then, under the Environment tab select Custom for the Python Path, click on the View as Text button and paste in the extra path.

You will need to redo this if you move the app engine installation, or you can use ${WING:PROJECT_DIR} to convert those paths to base on the location of the project file.

Improving Responsiveness when Setting Breakpoints or Pausing

Out of the box, Google App Engine will sit in a select call for up to thirty seconds when it has nothing to do. This results in delays in setting breakpoints or pausing the debug process. To speed this up, go into tools/dev_appserver.py and change DEFAULT_SELECT_DELAY to a shorter value, such as 1.0.

Using Django

If you are using the Django via the app-engine-patch project, you need to use manage.py as your main debug file instead of dev_appserver.py and should follow the instructions in the Django How-To (except that the --noreload option is not supported). In particular, note the need to ignore the NameError exception at startup.

Related Documents

Wing IDE provides many other options and tools. For more information:

« 4.0. Using Wing IDE with DjangoTable of Contents4.2. Using Wing IDE with Plone »