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

Martin Aspeli optilude+lists at gmail.com
Sun Nov 29 10:00:30 EST 2009

Tim Hoffman wrote:
> Just re-inforcing this I almost never do IFoo. adaption as I am almost
> always using
> multiadapters and utilities so I completely forget about the IFoo
> adaption capability.
> Which means I always just write getAdapter as well as it seems more
> consistent to
> from an api consumption point of view.

I use the IFoo(x) to invoke an adapter (and IFoo(x, None) lookup for a 
fallback) a *lot*. As in, virtually in every piece of (Zope) software I 

I've also encouraged people to do that in at least three major pieces of 
documentation (including my book).

Similarly, answering a different part of this thread: I use custom 
adapter factories from time to time, and have documented them as useful 
practice. Normally, that's because I want to look up the adapter 
implementation from someplace else than the global registry (e.g. 
plone.portlets fishes a persistent object out of an annotation at one 
point), or because I want the ability to "abort" the annotation by 
returning None (plone.behavior does that - actually, plone.behavior is a 
good example of the former also).


Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book

More information about the Zope-Dev mailing list