
26 Aug
2005
26 Aug
'05
10 a.m.
On Fri, 26 Aug 2005 16:30:26 +1000 Andrew Bennetts 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?
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.
For me, raising CannotAdapt would be better choice. After all, getting an object that implements requested interface is the very thing what adaptation is used for.
If I, say, adapt WovenContext to ISession, I get a session object which does not implement the ISession interface itself. Absurdly.
--
jk