31 Mar
2004
31 Mar
'04
10:34 p.m.
zope@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