Martin Aspeli wrote:
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
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?
adapted = IFoo(conext, None):
if adapted is not None:
Zope3-users mailing list