[Zope] get properties in external methods

Dieter Maurer dieter@handshake.de
Fri, 22 Nov 2002 20:10:23 +0100


Elena Schulz writes:
 > I want to get the properties and meta_type of objectId.
 > the following script doesn't work. Any hints?
When you report problems, you should add a precise problem
description, e.g. Error Type/Value and Traceback.

 > -- many thanks for your replies, Elena
 > 
 > (please answer directly to my adress so I get your reply sooner, thx)
 > 
 > def main(self, objectId):
 > 
 >     objectType = objectId.meta_type
This probably fails because "objectId" is likely (according to its
name) a string and not the object itself.

A string does not have an attribute "meta_type".

You use "getattr" to access an attribute given its name.
Therefore, the following may work:

       objectType= getattr(self,objectId).meta_type


Dieter