官术网_书友最值得收藏!

Debugging Zope exceptions with PDBDebug Mode

Whenever an exception is fired by some situation not foreseen during development, we can trace the exception in Zope logs or in the console itself. Many times during development, it's more useful to get direct access to the exception's context to better understand the problem. PDBDebugMode, a postmortem debugger, allows us to do that. It opens a pdb prompt to let us get our hands dirty.

How to do it…

  1. Add a Products.PDBDebugMode line in the eggs parameter of the [buildout] part.
    [buildout]
    ...
    
    # Add additional eggs here 
    eggs = 
        iw.debug 
        Products.DocFinderTab 
        Products.Clouseau
     Products.PDBDebugMode
    
  2. Rebuild the Zope instance:
     ./bin/buildout
    
  3. Test PDBDebugMode. As we said earlier, from now on every time Zope fires an exception (if running in debug mode), a pdb (not an ipdb though) will prompt us to inspect the context.
    • For an easy test, we must first tell Zope to pay attention to (that is, not ignore) the kind of exceptions we are going to produce. Open your browser and go to http://localhost:8080/plone/prefs_error_log_form and delete the NotFound line in Ignored exception types field (or you can also follow the ipzope example we included in Accessing an IPython powered shell earlier).
    • Then type any URL that you know doesn't exist, like http://localhost:8080/plone/doesnt-exist.

    Now check your console. You will see a pdb prompt waiting for you. Unluckily, this example is not a very good one because the exception was fired by the ZPublisher (try writing self in the console), so we can't see familiar code.

Note

You can suffer problems with PDBDebugMode such as triggering on at unexpected times, causing apparent slowness, or freezes. Thus, if your instance doesn't seem to be responding, check its console.

More information about PDBDebugMode is available at: http://plone.org/products/pdbdebugmode.

See also

  • Accessing an IPython powered shell
主站蜘蛛池模板: 融水| 清涧县| 房产| 宜州市| 上犹县| 乌鲁木齐县| 东兴市| 两当县| 铜陵市| 弥渡县| 本溪| 宁晋县| 南京市| 桃园县| 克什克腾旗| 资源县| 南充市| 兴海县| 阳新县| 台前县| 台前县| 缙云县| 南靖县| 涟水县| 平潭县| 修水县| 海门市| 鸡西市| 灵石县| 敦煌市| 普格县| 洞头县| 成安县| 商都县| 奉节县| 南召县| 通州区| 五指山市| 东乌珠穆沁旗| 晋州市| 潢川县|