[Zope-dev] improving the utility and adapter lookup APIs

Brian Sutherland brian at vanguardistas.net
Wed Nov 25 15:32:44 EST 2009


On Wed, Nov 25, 2009 at 05:17:17PM +0100, Thomas Lotze wrote:
> What about a simple and consistent API for all components including
> utilities, adapters and multiadapters:
> 
> IFoo()
> IFoo(x)
> IFoo(x, y)

This also doesn't allow you to use this (anti?)pattern:

class Foo:

    implements(IFoo)

    def do_something(self):
        # custom behaviour here
        default_foo_adapter = getAdapter(self, IFoo)
        return default_foo_adapter.do_something() # fallback to default behaviour

It may not be very theoretically correct, but it's something I find very
useful when writing IPublishTraverse implementing classes for
zope.publisher to traverse over. It saves me from having to inherit from
the default traverser.

-- 
Brian Sutherland


More information about the Zope-Dev mailing list