Hello, I tried <dtml-let item="sonstiges.help.sonstiges.err.getitem(_.str(httpcode))"> <dtml-if item> <dtml-var "item.title()"> <dtml-else> NO ITEM </dtml-if> <dtml-let> My "err" folder as several of DTML Methods which give an explanation for every HTTP error code. I want to retrieve that explanation. It has to be failsafe in cases where an explanation for the errorcode is missing. What is wrong with my code? Any ideas how to solve the problem? Thanks Ulrich
Ulrich Wisser writes:
I tried
<dtml-let item="sonstiges.help.sonstiges.err.getitem(_.str(httpcode))"> <dtml-if item> <dtml-var "item.title()"> <dtml-else> NO ITEM </dtml-if> <dtml-let> ... What is wrong with my code? Any ideas how to solve the problem? I see at least one problem (there may be more):
I do not expect that your "err" object implements a "getitem" method. You should get an "AttributeError getitem". When you are sure, that no object with an "HTTP" error code as name can be acquired, you can use: "_.getattr(...err,`httpcode`,_.None)" When you are not sure, you can try "_.getattr(...err.aq_explicit,`httpcode`,_.None)" This usually works, but it not truely safe. For a safe solution search the archives for "aq_base". Dieter
participants (2)
-
Dieter Maurer -
Ulrich Wisser