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

Chris McDonough chrism at plope.com
Tue Nov 24 15:27:05 EST 2009

Stephan Richter wrote:
> On Tuesday 24 November 2009, Chris McDonough wrote:
>>> Off the top of my head, another way to think of this might be to say
>>> that the 'dict access' is basically looking up a named utility
>>> providing a very generic marker interface, e.g.
>>> zope.component.interfaces.IUtility or even just
>>> zope.interface.Interface. That way reg['foo'] == getUtility(IUtility,
>>> name='foo'). Obviously, assignment would register in the same way.
>>> I'm not sure it's "better", though. :)
>> That would also be fine, and it would normalize things a bit, although the
>> implementation would be harder and it would result in slower lookups.  But
>> if it made folks feel better than inheriting from dict, I'd be +1 on it.
> I have not read the entire thread, but Martin's suggestion using 
> zope.interface.Interface makes a lot to sense to me as the dict syntax becomes 
> syntactic sugar and a simplification when desired.

I think it makes sense.  If we can relax the "utility name must be a string" 
restriction it would be the best solution I think.

I'll see what I can do.

- C

More information about the Zope-Dev mailing list