[Zope-dev] implementing zope.component 4.0

Charlie Clark charlie.clark at clark-consulting.eu
Mon Nov 30 15:38:32 EST 2009


Am 30.11.2009, 19:51 Uhr, schrieb Chris McDonough <chrism at plope.com>:

> + 1 with the following caveat:
> I think that method name should probably be "adapt"; "lookup"  should  
> maybe be
> a separate method reserved for passing bare interfaces rather than  
> objects
> which implement interfaces, e.g:
>   >>> IFoo.lookup(IBar)
>    <class FooBarAdapter>

I think that lookup is a registry function. Not sure if there is anything  
to be gained by making it available on the interface. But +1 on explicit  
methods over collapsing it into the language. I can see advantages of  
having a Pythonic idiom for this in the future as with set, dictionaries,  
etc. but at the moment I think the risk of confusion is greater than the  
shorthand advantage. However, I think this is going to turn out to be a  
matter of personal preference.

> This would be consistent with the nomenclature in the current  
> zope.interface
> AdapterRegistry API.
> If it would help to change the resulting error message to "adaptation  
> error"
> when ".adapt" is called, e.g.:
>   >>> IFoo.adapt(c, default='missing')
>    Traceback...
>    AdaptationError(...)

Having struggled to work out why I get the errors I do anything that  
provides more information as to why I can't adapt, ie. which interfaces  
are required I'd love something more than the current TypeError

Charlie
-- 
Charlie Clark
Managing Director
Clark Consulting & Research
German Office
Helmholtzstr. 20
Düsseldorf
D- 40215
Tel: +49-211-600-3657
Mobile: +49-178-782-6226


More information about the Zope-Dev mailing list