Re: implementing zope.component 4.0

Marius Gedminas <[email protected]>
Newsgroups gmane.comp.web.zope.devel
Message-ID <20091127141115.GA29436@platonas>
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

_______________________________________________
Zope-Dev maillist  -  [email protected]
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 )
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iD4DBQFLD94CkVdEXeem148RAovWAJjolHtICkdgtKSSctw0qX+9i60eAJ4oGPY/
ZrrfH2e/FWDV4YCHTzZYkA==
=lie9
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.