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

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

Meh, I just remembered that I tried this.  The current implementation requires 
that the "name" value be a literal string object (or at least something 
convertable to Unicode).  I think we could relax this requirement; it really 
only needs to be hashable.  I wouldn't want to deploy the API if the keys were 
required to only be strings.

- 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.