[Zope] Determining object type

Phil Harris phil@harris-family.info
Wed, 6 Mar 2002 16:52:05 -0000


meta_type is not always a simple type (i.e. string).  if you do if meta_type
== 'Folder' for instance it will fail, since meta_type for a folder is a
method.

using _.getitem returns a string, i.e. it renders it so to speak.

but I may always be talking out of my jacksee of course ;)

----- Original Message -----
From: "Joel Burton" <joel@joelburton.com>
To: "Phil Harris" <phil@harris-family.info>
Cc: <sherman.lambert@state.co.us>; <zope@zope.org>
Sent: Wednesday, March 06, 2002 4:51 PM
Subject: Re: [Zope] Determining object type


> On Wed, 6 Mar 2002, Phil Harris wrote:
>
> > <dtml-in expr="(objectValues('type1')) + (objectValues('type2')">
> >    <dtml-let mt="_.getitem('meta_type')">
> >    <dtml-if "mt=='type 1'">
> >         processing
> >   <dtml-else>
> >         processing
> >   </dtml-if>
> >   </dtml-let>
> > </dtml-in>
>
> Phil --
>
> Why the "_.getitem('meta_type')" followed by separate if statement?
>
> I'd have just done this as <dtml-if "meta_type=='xxx'">. Sometimes the
> _.getitem is required (if you don't know the attribute name, if you want
> to work w/o acquisition using aq_explicit, etc.).
>
> I guess I'm asking: are you being overly cautious/verbose, or is there
> some risk here in simply doing the </dtml-if meta_type> solution that I'm
> overlooking?
>
> --
>
> Joel BURTON  |  joel@joelburton.com  |  joelburton.com  |  aim:
wjoelburton
> Independent Knowledge Management Consultant