[Zope-dev] make zope.component.registry.Components inherit from dict?

Charlie Clark charlie.clark at clark-consulting.eu
Sat Nov 28 10:17:58 EST 2009


Am 24.11.2009, 04:24 Uhr, schrieb Chris McDonough <chrism at plope.com>:

> We've been handling some constructive criticisms from repoze.bfg  
> developers
> with respect to verbosity resulting from use of unnamed utility  
> registrations
> in a component architecture registry.
> These criticisms, and our ameliorations are detailed here:
> <http://docs.repoze.org/bfg/1.1/designdefense.html#bfg-uses-the-zope-component-architecture-zca>

An interesting document and discussion. Having struggled initially and in  
some ways still struggling to grasp the ZCA I can understand the  
temptation to try and hide it from developers "because they don't need it  
to get their job done". But my own take on the ZCA is that the component  
registry is nothing wildly complicated just significantly different from  
what many people are used to. But once you know it's there and that it  
just looks after components it's just like having a DBMS manage your data  
for you: throw stuff into it and it will manage your stuff for you.

I recently gave a presentation on the ZCA to non-Zopers and the concepts  
weren't too difficult for the audience (I find it helps to jazz up the  
metaphors). Conceptually the biggest problems are probably the multi-key  
(nature of component, interface, name) nature of the registry and the  
function of an interface as the token or smartcard required to get the  
desired component.

In the example

 from repoze.bfg.interfaces import ISettings
 from zope.component import getUtility
settings = getUtility(ISettings)

the biggest leap of faith is getUtility which makes a behind the scenes  
call to which registry is present. I can imagine a clearer implementation  
that would do the same but be explicitly dependent upon a particular  
registration.

registry.get((utility, ISettings, u''))

This would, of course, be available as a dictionary call, although I'm not  
sure I'd see great advantage in that. All assuming, of course, the  
implemntation didn't clash with a localSiteManager but I think from other  
posts that it does.

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