[Zope] two object is the same
Dieter Maurer
dieter at handshake.de
Wed Mar 31 17:34:31 EST 2004
zope at netchan.cotse.net wrote at 2004-3-30 13:15 -0600:
>In my unittest, I have to check that a specified zodb object is the same
>(e.g. not deleted and recreated) after an operation as it was before. I
>thought I could do this:
>
>ob = df._getOb(drid)
>[...] # do something
>if ob is not df._getOb(drid):
> # object changed
>
>('df' is inherited from Folder, 'ob' is from SimpleItem)
>
>However this doesn't work because the 'is' operator uses the memory
>address of the objects and these are not the same in subsequent calls:
Use "==" instead of "is".
Alternatives:
* use the "aq_base" attribute (it returns the non acquisition wrapped
base object) with "is"
* compare the "_p_oid" attribute or "absolute_url()" values.
--
Dieter
More information about the Zope
mailing list