[Twisted-Python] Interfaces and adapters

en.karpachov at ospaz.ru en.karpachov at ospaz.ru
Fri Aug 26 17:17:54 EDT 2005


On Fri, 26 Aug 2005 12:12:02 -0400
Itamar Shtull-Trauring wrote:

> > > 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
> necessary condition.

That's true, and I don't see how does it differ from my pseudocode example.
And neither the twisted.web.server.Session class implements, nor it's
objects provides the ISession interface.

-- 
jk




More information about the Twisted-Python mailing list