[Interface-dev] Re: [Zope3-dev] tagged value handling inconsequent for interface methods and attributes and interfaces themself

Jim Fulton jim at zope.com
Mon Oct 24 16:44:29 EDT 2005


Stephan Richter wrote:
> On Wednesday 19 October 2005 05:51, Grégoire Weber wrote:
> 
>>while modeling the external API of an application I'd like to use the
>>tagged value feature of the interface implementation.
>>
>>It seems to me that handling tagged values is implemented inconsequently.
> 
> 
> I plan to make a proposal that would allow the following:
> 
> import zope.interface
> 
> class IFoo(zope.interface.Interface):
> 
>   attr = zope.interface.Attribute('doc string')
> 
>   def method():
>     """doc string"""
> 
> interfaceTags = zope.interface.interfaces.ITaggedValues(IFoo)
> interfaceTags.someVariable = value
> 
> attributeTags = zope.interface.interfaces.ITaggedValues(IFoo['attr'])
> attributeTags.someVariable = value
> 
> methodTags = zope.interface.interfaces.ITaggedValues(IFoo['method'])
> methodTags.someVariable = value
> 
> Alternatively, I would like to try the following as well:
> 
> from zope.interface.interfaces import ITaggedValue
> 
> class IFoo(zope.interface.Interface):
> 
>   attr = zope.interface.Attribute('doc string')
>   ITaggedValues(attr).someVariable = value
> 
> Any comments before I spend time writing this up?

This won't work for tags whos keys are not python identifiers.
I'd like to encourage people to use ids (dotted names or urls) for
tags.

Jim

-- 
Jim Fulton           mailto:jim at zope.com       Python Powered!
CTO                  (540) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org


More information about the Interface-dev mailing list