[Zope-dev] zope.component: calling an Interface and calling queryAdapter give differing results

Philipp von Weitershausen philipp at weitershausen.de
Mon Sep 1 08:07:57 EDT 2008


El 30 Aug 2008, a las 07:50 , Dieter Maurer escribió:
> Chris Withers wrote at 2008-8-29 10:25 +0100:
>> Dieter Maurer wrote:
>>> Then, we could get rid of the "{get|query}[Multi]Adapter" altogether
>>> and consistently use "I(....)" with appropriate optional  
>>> parameters --
>>> what a simplification and homogenization :-)
>>
>> Yeah, but since when has simplification or homogenisation been a  
>> goal of
>> Zope 3? ;-)
>
> It was with the "Service" geddon: make "Service" and "Utility"  
> homgogenous.

Indeed.

I've personally thought for some time that it would be quite nice if  
all you had to do was call an interface to look up a utility (which is  
sort of a multi-adapter of order 0) or to do some kind of adaption, no  
matter how many objects you wanted to adapt. E.g.:

   auth = IAuthentication()                                 # utility
   auth = IAuthentication(default=None)
   langs = IUserPreferredLanguages(request)                 # adapter
   langs = IUserPreferredLanguages(request, default=None)
   view = IBrowserPage((obj, request), name='index')        # named  
multi-adapter

etc.

Personally I would favour such consistency higher than the current  
behaviour, which may have been invented intentionally but still causes  
confusion once in a while.



More information about the Zope-Dev mailing list