[Zope] Access object's class name (rather than meta_type)

Dieter Maurer dieter@handshake.de
Sun, 23 Feb 2003 21:09:20 +0100


Jon Whitener wrote at 2003-2-21 17:40 -0500:
 > Is there a way from Python to find objects according to their *class* 
 > name instead of by their meta_type?
 > 
 > Whereas it is easy to find objects by meta_type, e.g.
 > 
 >    list = context.objectValues('Page Template')
 > 
 > I need isntead to find them by the class name, i.e. the name that 
 > appears when you show a list of Zope objects, e.g. ZopePageTemplate in
 > 
 >    "<ZopePageTemplate at /foo/theTemplate>"

When you are ready to write an External Method:

     from Acquisition import aq_base

     def getClassName(obj):
       '''return the name of *obj* class.'''
       return aq_base(obj).__class__.__name__

As you need to access names starting with "_", you
cannot do it in TTW code but must use an External Method.


Dieter