Did not find a how-to for your problem?

Ask me to write the how-to post by writing to the mailing-list at cps-devel [@] lists [.] nuxeo [.] com or writing to me to joseluisdelarosa+cpshowto [@] gmail [.] com. Note: I'll keep all conversations on the official mailing list.

Wednesday, June 13, 2007

How to prepare the instance for the battle

Debugging is like go hunting, you have to set traps until you catch the bug. In CPS, with such an abstract architecture, where you set the trap is really important.

These words aim to let you know how to configure the Zope/CPS instance to make debugging tasks easier. Let's deploy the anti-bug guns:

  1. Run Zope in debug mode.
    Make sure your instance is running in debug mode by checking that the line

    debug-mode on

    is not commented in the file etc/zope.conf of the Zope's instance root folder.
  2. Download and use PDBDebugMode.
    This product will be the trap for any of our enemies. As soon as an exception arises, a command line debugger will let you frisk it. To get PDBDebugMode running, follow these steps:

    1. Setup Zope to run in debug mode as explained in the first point above.
    2. Download the product PDBDebugMode and extract it to the folder Products of the Zope's instance.
    3. Run Zope from command line in foreground mode. To do so, go to the root folder of the zope instance and execute

      joseluis@ayoros:~$ ./bin/runzope.

    Whenever an exception is thrown the browser will remain waiting and a prompt like this (Pdb) will hold on the command line for your orders. Entering the command “help” will display a list of all available commands.

    To set a breakpoint in the python code write a new line like this

    import pdb; pdb.set_trace()

    wherever you need to take a breath to scrutinize what is going on.

  3. Deactivate Crash shield
    Contrary to what would be done in any other dangerous situation in life, do deactivate the Crash Shield!!! Do it this way:

    1. Open the ZMI and go to the CPS object.
    2. Spread out the list of tools.
    3. Click on the tool portal_themes.
    4. Choose the tab Options
    5. Click the button “Deactivate the crash shield

    The duty of the crash shield is to show the symbols !!! blinking, which means that the code of a portlet is raising an exception. From the moment the crash shield is disabled, blinking !!! will not be shown anymore, instead the traceback of the error will be displayed or the (Pdb) prompt will be displayed in the terminal if it is enabled.

    Note: Each time the step Themes Tool of a profile is imported, it is possible that the state of the crash shield changes. That's because the configuration of this option is included in the profile. Exactly the line responsible for the configuration is in the file profiles/default/themes.xml and it looks like this:

    <property name="debug_mode">False</property>

    If you have already worked with profiles, you may be thinking that you can create a profile for debug and another one for production that set the property debug_mode to True and False respectively. Yes, that's a good shot.

No comments: