Here's a patch expressing the above example as a failing doctest. Not the best place for me to have put this, I'm sure, but here it is:
Index: src/zope/interface/adapter.txt =================================================================== --- src/zope/interface/adapter.txt (revision 98734) +++ src/zope/interface/adapter.txt (working copy) @@ -544,3 +544,33 @@ >>> registry.subscribe([IR1], None, handler) >>> registry.subscriptions([IR1], None) == [handler] True + + +Bugs +---- + +I don't know where to put this, so here you go. + + >>> from zope.interface import Interface, declarations, adapter + >>> import types + >>> class IFoo(Interface): pass + ... + >>> class Bar: pass + ... + >>> class Baz: pass + ... + >>> def f1(obj): pass + ... + >>> def f2(obj): pass + ... + >>> ar = adapter.AdapterRegistry() + >>> ar.register([declarations.implementedBy(types.ClassType)], IFoo, '', f1) + >>> ar.lookup1(declarations.providedBy(Bar), IFoo) #doctest: +ELLIPSIS + <function f1 at ...> + >>> declarations.implementedBy(Bar) + <implementedBy __main__.Bar> + >>> ar.lookup1(declarations.providedBy(Bar), IFoo) #doctest: +ELLIPSIS + <function f1 at ...> + >>> # Result is f1 + ... +
Here's a patch expressing the above example as a failing doctest. Not the best place for me to have put this, I'm sure, but here it is:
Index: src/zope/ interface/ adapter. txt ======= ======= ======= ======= ======= ======= ======= ======= ==== interface/ adapter. txt (revision 98734) interface/ adapter. txt (working copy) subscribe( [IR1], None, handler) subscriptions( [IR1], None) == [handler] AdapterRegistry () [declarations. implementedBy( types.ClassType )], IFoo, '', f1) declarations. providedBy( Bar), IFoo) #doctest: +ELLIPSIS implementedBy( Bar) declarations. providedBy( Bar), IFoo) #doctest: +ELLIPSIS
=======
--- src/zope/
+++ src/zope/
@@ -544,3 +544,33 @@
>>> registry.
>>> registry.
True
+
+
+Bugs
+----
+
+I don't know where to put this, so here you go.
+
+ >>> from zope.interface import Interface, declarations, adapter
+ >>> import types
+ >>> class IFoo(Interface): pass
+ ...
+ >>> class Bar: pass
+ ...
+ >>> class Baz: pass
+ ...
+ >>> def f1(obj): pass
+ ...
+ >>> def f2(obj): pass
+ ...
+ >>> ar = adapter.
+ >>> ar.register(
+ >>> ar.lookup1(
+ <function f1 at ...>
+ >>> declarations.
+ <implementedBy __main__.Bar>
+ >>> ar.lookup1(
+ <function f1 at ...>
+ >>> # Result is f1
+ ...
+