- Plone 3 Products Development Cookbook
- Juan Pablo Gimenez Marcos F.Romero
- 391字
- 2021-08-06 17:05:58
Taking advantage of an enhanced interactive Python debugger with ipdb
As a Python developer, you should already be familiar with pdb
. So think of ipdb
as a Python debugger with many of the advantages IPython provides. ipdb
, for example, is much easier to use thanks to the IPython autocomplete feature.
Note
You can find the official documentation for pdb
for Python 2.4 at http://www.python.org/doc/2.4.4/lib/module-pdb.html.
ipdb
has another very useful and important feature which is the ability to get an IPython shell in our instance console whenever we want by means of adding the /ipdb
suffix to any URL.
How to do it…
- Add the
iw.debug
line ineggs
parameter of[buildout]
part:[buildout] ... # Add additional eggs here eggs = iw.debug
- Insert an
iw.debug
line in thezcml
parameter of[instance]
part:[instance] ... # If you want to register ZCML slugs for any packages, # list them here. # e.g. zcml = my.package my.other.package zcml = iw.debug
- Rebuild your instance. We need to build our Zope instance again to let it know that there were some changes:
./bin/buildout
- Run your instance. Then run the instance in foreground mode to get a handle of its console:
./bin/instance fg
How it works…
Given that we haven't written any line of code yet, we won't call ipdb
from inside the (non-existing) code. What we need to know is that by adding these lines anywhere in the code, we will get the prompt from the improved debugger:
import ipdb; ipdb.set_trace()
But we do have a Plone site running, so let's try to get an IPython shell on demand. Access http://localhost:8080/plone/ipdb
and go to your foreground console.
There will be an ipdb
prompt waiting for you. Use the ll
command (double "L" in lowercase) to get a list of local variables. Then test some other things: context
, is the object we called ipdb
from, in our example, the Plone site. In this particular case, it also happens to be the portal
variable.

Note
More information about ipdb
can be found at: http://pypi.python.org/pypi/iw.debug.
- Adobe After Effects CC 高手之路
- 設計模式之禪(第2版)
- Hadoop核心技術
- Autodesk Ecotect Analysis 2011綠色建筑分析應用
- 畫筆圣經(jīng) Photoshop專業(yè)繪畫技法
- Word 2010實戰(zhàn)技巧精粹
- UI功夫:PC和APP界面設計全流程圖解
- Photoshop插畫藝術火星風暴
- Photoshop攝影后期必修5項核心技法 基本調(diào)整+光影校正+色彩修飾+局部處理+銳化降噪
- Autodesk Maya 2015標準教材II
- Photoshop CS5數(shù)字圖像處理
- 新手學UG NX 8.0輔助設計
- 一定要學的Photoshop人像攝影后期調(diào)色技法
- UG NX 6.0入門與提高
- 好學、好用、好玩的Photoshop 寫給初學者的入門書(第2版)