[Zope] Determining object type

Phil Harris phil@harris-family.info
Thu, 7 Mar 2002 00:19:03 -0000


Ooo, now I'm starting to take this personally ;)

Well, I've only really seen this occur in external Python code (external
method/Product).

So I may be being a tad anal about the check, but it seems sensible anyway.

<dtml-let mt=meta_type>

This may very well work, as it may be 'rendering' it in this usage.

caveat emptor, again, I may be seeing things through my shite colored
glasses ;)


----- 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 5:11 PM
Subject: Re: [Zope] Determining object type


> On Wed, 6 Mar 2002, Phil Harris wrote:
>
> > 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 ;)
> >
> > > 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?
>
> Interesting. For me (2.5.0), Folder.meta_type is a simple property. In
> fact, every object seems to have a simple string (grep -r "def meta_type"
> * in lib/python returned nothing except for PropertySheets.py)
>
> However, you're right: why risk it? Product WeirdFoo might emit a dynamic
> meta_type, strange though that would be.
>
> For clarity's sake, thought, wouldn't <dtml-let mt=meta_type> be
> sufficient over the _.getitem('xxx')? Again, not trying to pick on you,
> but wondering if I've overly liberal (always a threat) with my dtml-lets.
>
> --
>
> Joel BURTON  |  joel@joelburton.com  |  joelburton.com  |  aim:
wjoelburton
> Independent Knowledge Management Consultant