[Twisted-Python] Interfaces and adapters
itamar at itamarst.org
Fri Aug 26 12:12:02 EDT 2005
On Fri, 2005-08-26 at 16:30 +1000, Andrew Bennetts wrote:
> > 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?
If the adapter is a function, the function may not implement the
interface. The actual expected behavior is that the result of *calling*
the adapter *provides* the interface. An adapter class may well
implement the interface in order for this to happen, but it's not a
More information about the Twisted-Python