How to see if two objects are the same (minor fix)
**** From my previous post, it looked like the parent was changing. I had the first two lines swapped. Fixed below. ---- I want to see if an object is the one aqcuired from the root, but I'm hitting walls. <dtml-var "PARENTS[-1].myObject"> <dtml-var "myObject"> <dtml-var "PARENTS[-1].myObject is myObject"> This returns the following when in the root folder context: <TinyTable instance at 8684ad8> <TinyTable instance at 8684ad8> 0 It returns the following in a folder where there is another myObject: <TinyTable instance at 8684ad8> <TinyTable instance at 86709f8> 0 What am I missing in the comparison? Thanks! _______________________ Ron Bickers Logic Etc, Inc. rbickers@logicetc.com
Ron Bickers wrote:
This returns the following when in the root folder context:
<TinyTable instance at 8684ad8> <TinyTable instance at 8684ad8> 0
the above is a bit misleading ;-) The two objects aren't actually at the same address 'cos your comparison is actually of the acquisiton wrappers that are wrapping your TinyTable object...
<dtml-var "PARENTS[-1].myObject is myObject">
This comparison will never return true for that reason...
<dtml-var "PARENTS[-1].myObject == myObject">
...this one will return true in the next version of Zope, in the above example... To do comparisons like this, though, you really need to be in an external method or other unrestricted python so you can get access to .aq_base, which is the real object you're dealing with... have fun, Chris :-)
-----Original Message----- From: Chris Withers [mailto:fresh@bay-c.co.uk] Sent: Wednesday, October 11, 2000 3:16 PM To: Ron Bickers Cc: zope@zope.org Subject: Re: [Zope] Acquisiton Wrappers bite ;-)
<dtml-var "PARENTS[-1].myObject == myObject">
...this one will return true in the next version of Zope, in the above example...
To do comparisons like this, though, you really need to be in an external method or other unrestricted python so you can get access to .aq_base, which is the real object you're dealing with...
Thanks for the info. So, is there another way in DTML I can see if an object was acquired from PARENTS[-1] or not? Is there a way to check an objects container out of context? _______________________ Ron Bickers Logic Etc, Inc. rbickers@logicetc.com
Ron Bickers wrote:
<dtml-var "PARENTS[-1].myObject == myObject">
So, is there another way in DTML I can see if an object was acquired from PARENTS[-1] or not? Is there a way to check an objects container out of context?
Hmmm... try the following as a replacement for the above stuff: <dtml-var "myObject in PARENTS[-1].objectValues()"> cheers, Chris
participants (3)
-
Chris Withers -
Chris Withers -
Ron Bickers