Am Mittwoch 25 November 2009 17:54:53 schrieb Chris McDonough:
> Gary Poster wrote:
> > FWIW, I'm saying that utilities and adapters are different.  I share
> > your/Martijn's/other people's general thoughts about merging adapters and
> > multiadapters in the interface __call__ syntax.
> 
> There might should be more obvious APIs for just *retrieving* an adapter
>  based on a set of interfaces; it's useful to be able to retrieve an
>  adapter without invoking it.  Currently this is possible via
>  registry.adapters.loookup, which is fine.
> 
> And I know it's heresy, but sometimes I register something as an "adapter"
>  that is not callable with the number of arguments I'm adapting it with. 
>  Sometimes its convenient to register something that gets adapted using a
>  number of arguments that doesn't match the adaptation arguments.
> 
> If some set of ZCA APIs made it the responsibility of the *caller* to
>  invoke the adapter with arguments would go a long way between normalizing
>  the difference between utilities and adapters (because they would
>  essentially then be the same thing).
> 
> - C

I haven't been involed in the discussion so far and probably there are already 
enough colors for the bike shed in the game - anyway, I just want to add my 2 
Cent:

As has been pointed out, the semantics for adapters and utilities are a bit 
different: adapters are called on lookup, utilities are just returned. Maybe, 
it would be a good thing to convey this difference in the lookup-API, like:

IFoo(x) - adapt x to IFoo - which means lookup adapter and call it
IFoo.get() - return IFoo-Utility - which mean to simply lookup and return 
utility

This makes the semantic difference clear and allows for the (unusual, but maybe 
still valid) usecase of just returning an adapter for something without 
automatically calling it:

IFoo.get(x)

I don't remember when, but I think I once even had a use-case, where I wanted 
some Utility-like thing, which is not a singleton but a factory. That use-case 
would also be supported with:

IFoo()

Best regards,

Matthias
_______________________________________________
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )

Reply via email to