[Zope] Difference between id and getId()?

Thomas B. Passin tpassin@mitretek.org
Mon, 13 Aug 2001 18:19:47 -0400


In Python, an expressions like "obj.id" would normally return the value of
the "id" attribute of the "obj" object.  However in Zope, sometimes objects
have a ***method*** called "id()".  On such an object, asking for "obj.id"
returns the function object (a method is a function attached to an object),
rather than the value you would get by using the function to compute
something.

How can you tell whether an object uses an id attribute or an id() method?
Not easily, so use the getId() method instead.  Then you won't have to know
which is which.

Maybe it would have been better if Zope hadn't done it this way, but that's
how it is.

Cheers,

Tom P

[David Lambert]

I am a newbie to Zoip and apologize if this is a trivial question, but it
has
been giving me grief for several hours now.
I have found by experimentation that when iterating through a set of objects
and testing their ids that the following only seems to work ONLY for
folders:

<dtml-if "id == 'theObjectIdString'>
 ....
</dtml-if>

If however I use the code:

<dtml-if "getId() == 'theObjectIdString'>
...
</dtml-if>

all seems to work correctly. Obviously I am missing something very basic
here.