[Zope] Operator overriding not working with Zope class.

Etienne Labuschagne elabuschagne at gims.com
Tue Oct 26 04:39:13 EDT 2004


Sean Hastings wrote:

I don't think it is that as it is resolved correctly when using the 
__gt__ method explicitly.  p2.__gt__(p1) works fine, it is p2 > p1 that 
doesn't work.  Doing a inspect.getmro in the object's class also gives 
me (ZPerson, Person, ....) so it seems as if Person is second in the 
resolution order.  Since there is no __gt__ method defined in ZPerson, 
it should then resolve to Person's __gt__.

Etienne

>It might be an order of inheritance issue. Try changing the order in which
>you declare the parent classes:
>
>class ZPerson(ZopeClasseses, ..., Person):
>	....
>
>--Sean
>
>  
>
>>-----Original Message-----
>>From: zope-bounces at zope.org [mailto:zope-bounces at zope.org]On Behalf Of
>>Etienne Labuschagne
>>Sent: Tuesday, October 26, 2004 3:05 AM
>>To: zope at zope.org
>>Subject: [Zope] Operator overriding not working with Zope class.
>>
>>
>>I have two classes:
>>
>>class Person:
>>     ....
>>
>>class ZPerson(Person, ZopeClasses....):
>>     ....
>>
>>in Person 'n override __gt__, __lt__, and some others.
>>
>> >>> p1 = Person()
>> >>> p2 = Person()
>> >>> p1.age = 20
>> >>> p2.age = 30
>> >>> p2 > p1
>>True
>>
>>this doesn't work for the derived Zope class:
>> >>> p1 = ZPerson() #ok, I create this in the "proper" zope way and
>>                    #later retrieve it, but you get the idea
>> >>> p2 = ZPerson()
>> >>> p1.age = 20
>> >>> p2.age = 30
>> >>> p2 > p1
>>False
>> >>> p2.__gt__(p1)
>>True
>>
>>For some reason my __gt__ is not used when using the > operator.  If
>>called explicitly, it works properly.
>>
>>Any ideas?
>>
>>Etienne
>>_______________________________________________
>>Zope maillist  -  Zope at zope.org
>>http://mail.zope.org/mailman/listinfo/zope
>>**   No cross posts or HTML encoding!  **
>>(Related lists -
>> http://mail.zope.org/mailman/listinfo/zope-announce
>> http://mail.zope.org/mailman/listinfo/zope-dev )
>>    
>>



More information about the Zope mailing list