Difference between id and getId()?
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. TIA Dave.
This was the reason getId was introduced. You'll probably find that 'id' is also a method. Try id() and you may be surprised. Phil ----- Original Message ----- From: "David Lambert" <dave_lambert@fbcc.com> To: <zope@zope.org> Sent: Monday, August 13, 2001 10:54 PM Subject: [Zope] Difference between id and getId()?
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.
TIA
Dave.
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Thanks for your quick reply Phil. I think I understand a little more now, but why does id work for folders? TA Dave. On Monday 13 August 2001 17:00, Phil Harris wrote:
This was the reason getId was introduced.
You'll probably find that 'id' is also a method.
Try id() and you may be surprised.
Phil ----- Original Message ----- From: "David Lambert" <dave_lambert@fbcc.com> To: <zope@zope.org> Sent: Monday, August 13, 2001 10:54 PM Subject: [Zope] Difference between id and getId()?
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.
TIA
Dave.
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Cos, in the beginning was Zope and then Zope became confusing with methods and attributes of the same name, so we had id and id() on differing object types. That's why we have getId. Easy it wasn't. If you stick to getId you'll do OK. hth Phil ----- Original Message ----- From: "David Lambert" <dave_lambert@fbcc.com> To: "Phil Harris" <phil.harris@zope.co.uk>; <zope@zope.org> Sent: Monday, August 13, 2001 11:17 PM Subject: Re: [Zope] Difference between id and getId()?
Thanks for your quick reply Phil. I think I understand a little more now, but why does id work for folders?
TA Dave.
On Monday 13 August 2001 17:00, Phil Harris wrote:
This was the reason getId was introduced.
You'll probably find that 'id' is also a method.
Try id() and you may be surprised.
Phil ----- Original Message ----- From: "David Lambert" <dave_lambert@fbcc.com> To: <zope@zope.org> Sent: Monday, August 13, 2001 10:54 PM Subject: [Zope] Difference between id and getId()?
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.
TIA
Dave.
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
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.
Thanks Tom, Your answer also clears up my last question. Zope appears to have a few wrinkles around the edge which the newbie need to get used to. Nevertheless, it seems to be an excellent platform overall, well worth the initial pain! Cheers, Dave. On Monday 13 August 2001 17:19, Thomas B. Passin wrote:
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.
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (3)
-
David Lambert -
Phil Harris -
Thomas B. Passin