0

I'm looking for a good way to handle errors in Zope's page templates. What I already know is:

<div ... tal:define=...
         tal:on-error="string:Oops!">
  This text will be replaced in case of errors
</div>

or

<div ... tal:define=...
         tal:on-error="error/value">
  This text will be replaced in case of errors
</div>

or

<div ... tal:define=...
         tal:on-error="string:${error/type}: ${error/value}">
  This text will be replaced in case of errors
</div>

However, it might be desirable to use a more elaborated error handling method, e.g.

  • to display details depending on certain permissions
  • to log and/or report the error to the maintainers
  • to have an easy way to create some pretty HTML without the need of a lot of code in the template

I had a look at the old Zope documentation page and created a script object like described there (amending the missing colon, of course); however, it won't work (I tried both on-error="here/errHandler" and on-error="here/scripts/errHandler", and I added *args and **kwargs, without success).

I tried to build a browser (on-error="here/@@talerror") for such purposes, and it was used alright, but it didn't seem to get the error object.

I'm using Zope 2.10.7-final and Plone 3.3 (old, I know).

Is there a way to hand over the error object to the browser, or to make the script object work?

P.S., just to get it clear: This is not about sqeezing lots of logic in a template - no sermons about templates and logic, please! My goal is to find the error in existing templates, i.e. which part of the logic (which is implemented somewhere behind the scenes, in browsers etc.) fails in which way. The documented way of using an error script doesn't work for me (maybe I'm missing an important part?), and an error handling browser apparently doesn't have access to the error object.

4

0 回答 0