__cmp__ in python classes?
Hi, I've got a system I'm developing that has a bunch of Python classes that I'm using. One of these classes defines a __cmp__ method, but it doesn't appear to be being called when I test for equality of two objects. I checked to see whether it was Acquisition that was making it interesting but even when I got the object directly it wasn't calling my __cmp__ method. Does Zope ignore __cmp__ methods? If so, is there any way around it? -- Benno Rice "No, no. We're *sweet* and XNFP Aries Dark Subculture- *innocent* evil bastards." friendly Internet Geek benno@netizen.com.au "Defend your joy"
Benno Rice wrote:
Hi,
I've got a system I'm developing that has a bunch of Python classes that I'm using. One of these classes defines a __cmp__ method, but it doesn't appear to be being called when I test for equality of two objects.
I checked to see whether it was Acquisition that was making it interesting but even when I got the object directly it wasn't calling my __cmp__ method.
Does Zope ignore __cmp__ methods?
Not in general. The short answer is that it is a bug in acquisition. (There's a longer answer having to do with a wrinkle in Python's comparison rules. Two objects are compared by address if they have different types unless the types are numberic types. Acquisition doesn't implement the numeric protocols. With ExtensionClass, every class defined a new type.)
If so, is there any way around it?
A long time ago, Mike Pelletier developed a patch to Acquisition.c that fixes this by implementing enough of the numeric protocol to make this work. I've never gotten around to checking this in. (Bad me.) Mike, do you still have this? Would you mind checking this in? (Now that you work for DC. :) Jim -- Jim Fulton mailto:jim@digicool.com Technical Director (888) 344-4332 Python Powered! Digital Creations http://www.digicool.com http://www.python.org Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats.
On Tue, 14 Dec 1999, Jim Fulton wrote:
A long time ago, Mike Pelletier developed a patch to Acquisition.c that fixes this by implementing enough of the numeric protocol to make this work. I've never gotten around to checking this in. (Bad me.)
Mike, do you still have this? Would you mind checking this in? (Now that you work for DC. :)
I thought this looked familliar. Unfortuantely, I don't have that patch anymore. I squeezed some old brain cells REALLY hard, and I think I recall trick. It's only a few lines, let's see if I can recreate it today. BTW, AFAIK I don't have the ability to commit to the CVS tree. Mike. -- Mike Pelletier email: mike@digicool.com Mild mannered software developer icq: 7127228 by day, super villain by night. phone: 519-884-2434
Mike Pelletier wrote:
On Tue, 14 Dec 1999, Jim Fulton wrote:
A long time ago, Mike Pelletier developed a patch to Acquisition.c that fixes this by implementing enough of the numeric protocol to make this work. I've never gotten around to checking this in. (Bad me.)
Mike, do you still have this? Would you mind checking this in? (Now that you work for DC. :)
I thought this looked familliar. Unfortuantely, I don't have that patch anymore. I squeezed some old brain cells REALLY hard, and I think I recall trick. It's only a few lines, let's see if I can recreate it today.
Let me search my old mail first.
BTW, AFAIK I don't have the ability to commit to the CVS tree.
Hm. OK, assuming I find your mail, I'll check it in. This probably won't happen till tomorrow. Jim -- Jim Fulton mailto:jim@digicool.com Technical Director (888) 344-4332 Python Powered! Digital Creations http://www.digicool.com http://www.python.org Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats.
On Tue, Dec 14, 1999 at 01:52:22PM +0000, Jim Fulton wrote:
Mike Pelletier wrote:
On Tue, 14 Dec 1999, Jim Fulton wrote:
A long time ago, Mike Pelletier developed a patch to Acquisition.c that fixes this by implementing enough of the numeric protocol to make this work. I've never gotten around to checking this in. (Bad me.)
Mike, do you still have this? Would you mind checking this in? (Now that you work for DC. :)
I thought this looked familliar. Unfortuantely, I don't have that patch anymore. I squeezed some old brain cells REALLY hard, and I think I recall trick. It's only a few lines, let's see if I can recreate it today.
Let me search my old mail first.
BTW, AFAIK I don't have the ability to commit to the CVS tree.
Hm. OK, assuming I find your mail, I'll check it in. This probably won't happen till tomorrow.
Thanks guys, I really appreciate it. =) Looking forward to the patch. -- Benno Rice "No, no. We're *sweet* and XNFP Aries Dark Subculture- *innocent* evil bastards." friendly Internet Geek benno@netizen.com.au "Defend your joy"
participants (3)
-
Benno Rice -
Jim Fulton -
Mike Pelletier