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:

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):

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):

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

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

Reply via email to