Enfold Debugging Tools

Enfold Debugging Tools

Enfold Debugging Tools

Enfold Server's log files can be a useful resource for diagnosing problems on Enfold Server.

Your installation of Enfold Server(ES) includes several Windows tools for debugging Plone and Python programs.

images/debugtoolsmenu.png

Plone Debug Client

Plone debug client is a Zope client attached to a Windows console. It shows the standard output and standard error of a running Zope client in debug mode. It also allows you to interact with the Plone site via the command line.

Another product, Clousseau (http://plone.org/products/clouseau-- not included with Enfold Server) performs many of the same functions within a browser window (thus providing cross-platform use). Clousseau is open source and created by an Enfold developer. Plone debug client's main advantage is that it provides more security in a production environment. Clousseau is not recommended except in a controlled testing environment.

How to Start Plone Debug Client

Go to Start > Programs > Enfold Server > Development > Plone Debug Client

Note: Plone debug client needs to run on the management port you have configured for your first client. (Normally, that is 8080). If you want to run Plone debug client on a machine running Enfold Server in production, you need at least one more Zope client to be available from Encontrol.

  1. Make sure you have a second client running on a different port (such as 8081). You can create one with Encontrol. For more information, see Using Encontrol .
  2. Start the second client with Encontrol.
  3. Turn off the first client.
  4. Open up the Plone debug client.

Note: Plone debug client will always run in debug mode. It is not necessary to switch your Zope client to debug mode in the Encontrol configuration utility. However, you will need to be sure that you have a second client running on a different port and that the first client is not running.

Important: Because Plone debug client provides a lot of debug information, it consumes a lot of RAM and system resources. It should be kept off most of the time unless you are trying to debug a problem.

What is Debug Mode?

Zope clients run in two different modes: standard and debug mode. Debug mode is more verbose but slower; you should normally not run a Zope clients on a production machine to run in debug mode. Running Plone Debug client puts a running Zope client in debug mode inside your terminal window.

How do debug mode and normal mode differ?

  • Errors in Products in debug mode cause a fatal error, rather than failing silently.
  • Debug mode causes Zope to perform additional 'sanity' checks which are useful for tracking down problems (even though they can help track down problems).
  • In normal mode, Zope keeps templates in memory after starting; in debug mode, skins elements (such as Zope templates) are refreshed automatically.

Using Plone Debug Client with PDB

A Python debugger like pdb need to be attached to a Windows console to work.

Here's another example of how Plone Debug client can be used to identify problems.

If you install a third party Plone product called pdb-debug- mode (http://plone.org/products/pdbdebugmode/) on Enfold Server, when your browser encounters an error, the Plone Debug client will show the exact line of code at which Plone failed. (you must have Plone debug client open). (Note: this use of Plone Debug client is not officially supported by Enfold).

Steps:

  1. Install pdbdebugmode in Products directory.
  2. open Plone debug client
  3. access Plone URL via web browser.

Alternatively, the commercial Python IDE editor, WingIDE ( http://www.wingware.com/doc/howtos/plone) provides a GUI debugger for Zope/Plone.

Plone Shell

Plone Shell lets you interact safely with the live ZODB in a relatively safe environment. Not only can you view objects and classes from a python interface, you can also try code and commands and see what the output would be without having to commit to the changes. (To commit a command inputted through the Plone Shell, you will need to type:

import transaction; transaction.commit()
app._p_jar.sync()

The first line commits your command. The second line synchronizes this with the remaining Zope clients.

Here are some ways the Plone Shell can be useful.

  1. Provides access to ZODB when ZMI is down or available. (plone shell only has access to ZODB)
  2. Can run a script directly without having to deal with Zope security.
  3. Can do import/export data with scripts from the command line
  4. Can let you test code within a live server environment with relatively little risk

Plone Debug Server

This utility lets you see the output and errors from the Zope Enterprise Objects (ZEO) Server. You can run this whenever ZEO Server is running. ZEO server does not yield as much useful information as Plone Debug client.

To run this utility, go to Start > Programs > Enfold Server > Development > Plone Debug Server

Plone Test

If you call up the Plone Test utility, that will run a preassembled battery of tests on the Server. Generally, this verifies that the libraries have been installed correctly or that the files are all there.

To run this utility, go to Start > Programs > Enfold Server > Development > Plone Tests

The results are available at C:\Program Files\Enfold Server\Python\Lib\site-packages\EnfoldTools\Cluster\util (or some place similar).

Python Shell and Windows Shell

Enfold Server also includes two interactive python shells for testing.
  • Python
  • PythonWin

PythonWin is a Python IDE which includes Python Windows extensions, a Python prompt and a Python text editor. You can start this at Start > Programs > Enfold Server > Development > PythonWin

Setup Environment

The Setup Environment utility lets you have access to your Plone environment in a command window where you can run Windows commands on the file system.

This is helpful for:

  • performing file system operations

  • using buildout/easy_install to download new application eggs or products. (Buildout/Ploneout is a new way to download python libraries and update Plone products).

    images/setupenviron.png

Using easy_install with Enfold Server

New methods have emerged for updating python libraries and Plone products. One such method called Easy Install lets you install and update Plone products and libraries via an easy command line tool. (You can read some background information on easy install at http://peak.telecommunity.com/DevCenter/EasyInstall).

  1. Sign on as the user who installed Enfold Server (or a domain user with local Administrator privileges).

  2. Go to Start --> Enfold Server --> Development --> Setup environment. Setup environment is the terminal command prompt that uses the python path and Plone variables that coincide with your Enfold Server installation.

  3. Run the easy_install command. You will not need to type the path because the Setup Environment tool already sets these things up for you. Here's an example:

    C:\\Program Files\\Enfold Server\\Python>easy_install feedparser
    

Note You should not run easy_install from a python prompt on a Windows command line. This is because the Windows command line may not have set the python path/variables properly or may reference another version of Python installed on your Windows machine. The Setup Environment tool included with Enfold Server has already set the python path and variables to coincide with your Plone install. For this reason, running the command from the Setup Environment tool is more likely to work.

  1. Verify that the new egg has been successfully installed. If the import command executes without giving an error, that means the egg has been successfully installed.

    C:\\Program Files\\Enfold Server\\Python>python
    Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import FeedParser
    >>>
    
  2. Restart Enfold Server.

Products directory vs. easy_install

Installing products by downloading them into your Products directory is similar to using easy_install. In some cases, you may be able to install/update by using either method.

Generally though, easy_install should be used when updating python libraries relevant to Plone or installing libraries in addition to the product itself; if you are just installing/upgrading a Plone product, you should not use easy_install unless you have to.