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:
try: ... raise "asdf" ... except "asdf": ... print "test" ... except: ... print "notest" ... test
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> But, the stringExc is rosen(?) as a 'real' Exception class, so <dtml-except stringExc> would work - which is not clearly at first sight. In the ZopeBook there is a hint on <dtml-raise type="404"> asdf </dtml-raise> which comes up to be the most clean way. The complete working example, most clean imo is following: <dtml-try> <dtml-raise type="userDefined"> asdf </dtml-raise> <dtml-except userDefined> asdf </dtml-except> Any comments on that? Btw: am i getting only responses if i turn of GPG Signaturing? -- Christian Theune - ct@gocept.com gocept gmbh & co.kg - schalaunische strasse 6 - 06366 koethen/anhalt tel.+49 3496 3099112 - fax.+49 3496 3099118 mob. - 0178 48 33 981 reduce(lambda x,y:x+y,[chr(ord(x)^42) for x in 'zS^BED\nX_FOY\x0b'])
Btw: am i getting only responses if i turn of GPG Signaturing?
If its turned on I only see the message as an attachments ('cos Outlook Express is pretty dumb), which I cant be bothered to open and hence rarely respond. Cheers. -- Andy McKay.
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
participants (3)
-
Andy McKay -
Christian Theune -
Dieter Maurer