[Zope] getitem?

Dieter Maurer dieter@handshake.de
Thu, 14 Feb 2002 22:54:26 +0100


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