[Twisted-Python] Interfaces

Glyph Lefkowitz glyph at twistedmatrix.com
Thu Apr 17 02:10:06 MDT 2003


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wednesday, April 16, 2003, at 10:27 PM, Christopher Armstrong wrote:

> I like Interface inheritance, and I don't think anyone has really 
> objected to
> it yet.

I have :-).

The problem is that currently, it doesn't do what you think.  What most 
people want an interface inheritance to do is make

     class IFoo(Interface): pass
     class IBar(IFoo): pass
     class Bar:
         __implements__ = IBar

be more or less equivalent to

     class IFoo(Interface): pass
     class IBar(Interface): pass
     class Bar:
         __implements__ = IFoo, IBar

Currently this does _not_ happen, because

Does this "DWIM" in Zope?  I have been hesitant to make 
python.components handle it this way, firstly because we didn't realize 
it at first and so it would now be a change in semantics, and secondly 
because it's not clear what effect this would have on registerAdapter.  
Would

     registerAdapter(Bar, Baz, IBar)

also register an adapter for Baz for IFoo?  Why or why not?  What if a 
different adapter was already registered?  I could see that taking 
interface inheritance into account here could be sometimes convenient, 
but it could also be sometimes wrong.  I really have no idea what the 
right answer is, and so leaving it "inconvenient but simple" was easier 
for the time being.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (Darwin)

iD8DBQE+nmFjvVGR4uSOE2wRAizjAJ9jF1XYx/3Arc31I8vK4SQnOkDi9gCgj6kk
cqnpAdkXmb4T8T3zOOT75oM=
=uG4y
-----END PGP SIGNATURE-----





More information about the Twisted-Python mailing list