[Zope] Documentation Bug
Dieter Maurer
dieter@handshake.de
Mon, 27 Aug 2001 21:04:29 +0200 (CEST)
Christian Theune writes:
> The DTML Documentation has a slight difference to the real world in it:
>
> The description is as follows:
> raise tag syntax:
> <dtml-raise ExceptionName|ExceptionExpression>
> </dtml-raise>
>
> but the "expression" is confusing when you want to use
> userdefined expressions. In plain python it goes following way:
The expression is when you want non-constant exceptions, given
by an expression, e.g.
<dtml-raise expr="mapping and {}[key] or object.key">
This raises a "KeyError" or an "AttributeError" dependent
on "mapping".
> So this, combined with the upper description seems to be as following:
>
> <dtml-try>
>
> <dtml-raise "'stringExc'"> asdf </dtml-raise>
>
> <dtml-except "'stringExc'"> your error code here
>
> </dtml-try>
"dtml-except" does not support "expr" arguments.
Thus, "'stringExc'" is interpreted as the exception
"'stringExc'" and this is not the same as "stringExc".
"dtml-raise" interprets the "..." as expr-argument
and evaluates the content. The result is the exception
"stringExc".
> ...
> In the ZopeBook there is a hint on <dtml-raise type="404"> asdf </dtml-raise>
> which comes up to be the most clean way.
It does not matter whether or not you enclose the "type" attribute value
in "...".
> The complete working example, most clean imo is following:
> <dtml-try>
>
> <dtml-raise type="userDefined"> asdf </dtml-raise>
>
> <dtml-except userDefined> asdf
>
> </dtml-except>
You can omit the "..." around "userDefined", if you like.
> Btw: am i getting only responses if i turn of GPG Signaturing?
I do not think so, although it is noise in my view.
This is a technical discussion group; we do not need to
verify identities....
Dieter