我正在寻找一种处理Zope页面模板错误的好方法。我所知道的是:
<div ... tal:define=...
tal:on-error="string:Oops!">
This text will be replaced in case of errors
</div>
或
<div ... tal:define=...
tal:on-error="error/value">
This text will be replaced in case of errors
</div>
或
<div ... tal:define=...
tal:on-error="string:${error/type}: ${error/value}">
This text will be replaced in case of errors
</div>
然而,可能需要使用更精细的错误处理方法,例如
我查看了old Zope documentation page并创建了一个类似于那里描述的脚本对象(当然要修改缺少的冒号);但是,它不起作用(我尝试了on-error="here/errHandler"
和on-error="here/scripts/errHandler"
,我添加了*args
和**kwargs
,但没有成功。)
我尝试为此目的构建一个浏览器(on-error="here/@@talerror"
),并且它被正常使用,但它似乎没有得到error
对象。
我正在使用Zope 2.10.7-final和Plone 3.3(旧的,我知道)。
有没有办法将error
对象移交给浏览器,或者让脚本对象有效?
P.S。,只是为了弄清楚:这是不关于在模板中广泛使用大量逻辑 - 请不要关于模板和逻辑的讲道!我的目标是在现有模板中找到错误,即逻辑的哪个部分( 在幕后某处,在浏览器等中实现)以哪种方式失败。记录的使用错误脚本的方法对我不起作用(也许我错过了一个重要的部分?),错误处理浏览器显然无法访问错误对象。