Yet Another PEP: Query Protocol Interface or __query__

Huaiyu Zhu hzhu at mars.localdomain
Wed Mar 21 04:03:28 EST 2001


On Wed, 21 Mar 2001 14:06:07 +1100, Delaney, Timothy <tdelaney at avaya.com> wrote:
>So far as I can see, this PEP does not solve one basic problem - interfaces
>which the class writer doesn't know about.
>
>For example, I have an interface, mapped to "org.mydomain.something". Then I
>have a slightly different interface mapped to "org.mydomain.somethingelse".
>
>I have a class which implements org.mydomain.something. However, whilst it
>can perfectly implement org.mydomain.somethingelse, it would be rejected as
>it doesn't actually know about it.

This is not difficult to solve.  See 

http://www.geocities.com/huaiyu_zhu/python/Interface/typecheck.txt

Just change the file name to typecheck.py to test if it does what you want.

The idea is that instead of a class stating what interfaces it belong to,
and interfaces actively states what it covers.  This allows inclusion of
things into an interface based on various criteria:
- instantance of class
- having a given method
- is of a specific type
- is a particular object
- etc

This also allows both interetance base on classes and reversed inheritance
based on interfaces themselves.

>I may well just try implementing this some time ... most of it shouldn't be
>too hard. Unfortunately, I've got a nasty deadline coming up ... :(

That implementation has been sitting on my page for many months now :-)
I think I mentioned it here once.  Maybe I should just post it here,
as most people don't usually follow links.

-- 
Huaiyu Zhu   <hzhu at users.sourceforge.net>



More information about the Python-list mailing list