On Aug 25, 2005, at 11:30 PM, Andrew Bennetts wrote:
On Fri, Aug 26, 2005 at 10:17:07AM +0400, en.karpachov@ospaz.ru wrote:
Let's say we defined an interface and an adapter:
class IFoo(zope.interfaces.Interface): pass
twisted.python.components.registerAdapter(Foo, Bar, IFoo)
As it is for now, the registerAdapter accepts any Foo, without regarding what it implements.
It has to accept pretty much anything -- adapters can be e.g. functions as well as classes.
Could somebody give any rationale why this condition shouldn't always hold:
foo = IFoo(bar) assert IFoo.providedBy(foo)
Seems it is not unreasonable to expect this behaviour, because it is exactly what interfaces are all about, or am I wrong?
That's a pretty reasonable expectation. I think emitting a warning if this doesn't hold would be a sane thing to do, and it wouldn't break any code.
It would certainly slow it down, though. I think this is a "consenting adults" kind of scenario. If someone registers an adapter, they probably didn't do it by accident! -bob