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:
- 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. - 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:- Setup Zope to run in debug mode as explained in the first point above.
- Download the product PDBDebugMode and extract it to the folder Products of the Zope's instance.
- 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. - 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:- Open the ZMI and go to the CPS object.
- Spread out the list of tools.
- Click on the tool portal_themes.
- Choose the tab Options
- 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:
Post a Comment