I'm probably doing something very wrong, but ...
I have a general interface that can either by directly provided by an
object or class (typically with implements() on the class), but could also
be provided via an adapter. I have a few places where I just need to check
for this (it's not really a marker interface, but I need to know whether
other code later on would be able to use the interface or not).
In my tests, I tried to use queryAdapter(), but that didn't return
anything when the interface was implemented directly by the class.
Similarly, Interface.providedBy() returns (expectedly) False if the
interface could only be obtained via an adapter. Currently I do:
adapted = IFoo(context)
except (ComponentLookupError, TypeError):
but that's just silly... Is there a pattern for this?
"You can just adapt yourself out of it..." // Archipelago sprint 26/04/2006
Zope3-users mailing list