make zope.component.registry.Components inherit from dict?

Chris McDonough <[email protected]>
Newsgroups gmane.comp.web.zope.devel
Message-ID <[email protected]>
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>

In repoze.bfg, we've actually decided to use a subclass of the component 
registry which also inherits from "dict".  This makes it possible to spell 
common unnamed "utility" registrations and lookups as:

utility = SomeUtilityImplementation()
registry['someutility'] = utility
someutility = registry['someutility']

Instead of the more familiar:

class ISomeUtility(Interface):
     pass

utility = SomeUtilityImplementation()
registry.registerUtility(utility, ISomeUtility)

Doing this was extremely simple.  Here's the "meat" of the subclass:

from zope.component.registry import Components

class Registry(Components, dict):
     pass

I think it would be reasonable to make this change in zope.component itself. 
Dissenters?

- C
_______________________________________________
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 )
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.