[Zope-dev] implementing zope.component 4.0

Marius Gedminas marius at gedmin.as
Fri Nov 27 09:11:15 EST 2009


On Fri, Nov 27, 2009 at 02:38:55PM +0100, Martijn Faassen wrote:
> I'd ask people to think about this approach without considering 
> backwards compatibility issues first. Especially given the goal "making 
> component lookup disappear into the language" makes me think just all 
> making it calling an interface would be the most elegant approach.

You're convincing.

(I just can't force myself ignore backwards-compatibility issues, I
suppose.)

> So imagining we didn't have to worry about backwards compatibility, 
> would you still propose that API, making a difference between adapter 
> and utility lookup?

Yes.

> What's the motivation?

The "utilities must be singletons" logic hardcoded in the ZCA.

provideAdapter(factory, adapts=(one, two, three))
provideAdapter(factory, adapts=(one, two))
provideAdapter(factory, adapts=(one, ))

The natural progression, to me, is

provideAdapter(factory, adapts=())

rather than

provideUtility(singleton)

If we decide, ignoring BBB concerns, to make

  provideUtility(singleton, provides=IFoo)

be equivalent to

  provideAdapter(lambda: singleton, adapts=(), provides=IFoo)

then I'd be very happy to use

  IFoo()

for utility lookup.

This also assumes that I'm free to

  provideAdapter(arbitrary_callable, adapts=()) 
  
and use computed-utility-lookup, or even create utilities on demand in
my arbitrary_callable.

Three cheers for utility and empty-tuple-adapter unification!

> And would you deprecate plain 
> adapter calls and prefer 'adapt' all the time?

Ignoring BBB, and assuming utilities-are-just-adapters-on-empty-tuples,
then I'd prefer to use your proposed IFoo(*args, **kw) syntax.
The more I think about it, the more I like this solution.


Ignoring BBB and assuming utilities are distinct fowl, I'd prefer to
have just IFoo.adapt(*args, **kw) and IFoo.utility(**kw).

The phrasing of your question ("deprecate") makes ignoring BBB
impossible, in which case I'd prefer to have a 100% backwards-compatible
IFoo(single_arg, [default]) + IFoo.adapt(*args, **kw) +
IFoo.utility(**kw).

> So as to prevent bikeshedding the API too much, I'm going to take your 
> +0.5 anyway. :)

Marius Gedminas
-- 
http://pov.lt/ -- Zope 3 consulting and development
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mail.zope.org/pipermail/zope-dev/attachments/20091127/852c17eb/attachment.bin 


More information about the Zope-Dev mailing list