Get object by object id
What is the easiest way to get an object value given the object id? There is an API method objectValues('MetaType'), but I couldn't find a method analogous to getObject(objectId). Currently I'm getting all objects in the container with objectValues() and then iterating through them checking their id until I find the needed object. I suspect there is a better way that I'm not aware of. Any suggestions? --Borislav
You can use dictonary syntax: folder[id] -- Marco Catunda On Thu, 2002-09-05 at 18:58, Borislav wrote:
What is the easiest way to get an object value given the object id? There is an API method objectValues('MetaType'), but I couldn't find a method analogous to getObject(objectId). Currently I'm getting all objects in the container with objectValues() and then iterating through them checking their id until I find the needed object. I suspect there is a better way that I'm not aware of. Any suggestions?
--Borislav
On Thu, Sep 05, 2002 at 07:06:13PM -0300, Marco Catunda wrote:
You can use dictonary syntax:
folder[id]
... but you must handle the error if the object doesn't exist. You can also do: folder.get(id) # yields None if folder[id] doesn't exist -- Paul Winkler "Welcome to Muppet Labs, where the future is made - today!"
Borislav wrote:
What is the easiest way to get an object value given the object id? There is an API method objectValues('MetaType'), but I couldn't find a method analogous to getObject(objectId). Currently I'm getting all objects in the container with objectValues() and then iterating through them checking their id until I find the needed object. I suspect there is a better way that I'm not aware of. Any suggestions?
--Borislav
hi, you can use: getattr(containerObject,objectId) cheers, maik
participants (4)
-
Borislav -
Maik Jablonski -
Marco Catunda -
Paul Winkler