[Zope] How to see if two objects are the same (minor fix)

Tres Seaver tseaver@digicool.com
Fri, 13 Oct 2000 09:43:20 -0400


Ron Bickers <rbickers@logicetc.com> wrote:
> 
> **** 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?

You are seeing the result of a (mis)feature of acquisition:  the
objects you are comparing are actually AcquisitionImplicitWrappers
around the real 'myObject';  because the two wrappers are different,
and because the underlying object doesn't define a custom '__cmp__()'
method, the two wrappers are compared for identity (which is bogus).

I recently fixed this in response to a Collector issue:

 http://classic.zope.org:8080/Collector/1650/view

You can get the patch from that page, or just wait for Zope 2.3
(RSN, I'm sure).

Tres.
-- 
===============================================================
Tres Seaver                                tseaver@digicool.com
Digital Creations     "Zope Dealers"       http://www.zope.org