[Interface-dev] Tagged values

Stephen Waterbury golux at comcast.net
Mon Aug 22 20:40:43 EDT 2005


Jim Fulton wrote:
> Stephen Waterbury wrote:
> 
>> Zope Interface gurus:
>>
>> So far, I've read some of the z.i source, the introductory docs, and
>> played with it.  Right now I'm only concerned with Attribute
>> and Interface, and as far as I can see, no harm is done by giving
>> them direct attributes instead of tagged values for such things as
>> are shown in the README example ('author', 'date-modified').
>>
>> Is there some side-effect that I haven't thought of, or were
>> tagged values introduced mainly to avoid possible user confusion
>> of a direct attribute of an Interface with a contained Attribute
>> instance?
> 
> I don't know what you mean by a "contained attribute instance".

I meant an instance of Attribute whose name is contained in the
Interface:

python> 'a' in IFoo
True

Not a good thing to call it, since the Attribute instance itself
is not contained in the Interface -- only its name is.  I should
have called it "attribute-whose-name-is-contained-in-the-Interface".
;)

By "direct attribute", I meant one like *bar* in

IFoo.bar = 'baz'

>> My main question here is whether there are any known gotcha's to
>> giving Interface and Attribute (and other Elements) direct
>> attributes.
> 
> In general, I think it's a bad idea to add extra attributes to objects
> that you don't control.  Interfaces could grow an attribute/method with
> the same name as one you picked.

I agree.  So my meta objects that are somewhat Interface-like will not
have a class of their own -- just a special Interface and an adapter
that adapts an Interface to it -- that way I can define attributes for
it that *I* control.  So ha!  :)  And if Interfaces grow something new,
it's very unlikely that I'd need to expose it thru my adapted
Interface's Interface, since mine does everything it needs to do.

Yea, interfaces and adapters!

> I don't expect to prohibit setting extra attributes on interfaces, but I
> don't promise to support it either.  Certainly, IInterface makes no such
> promise. :)

Thanks for the warning, but I don't need IInterface to support it (since
I'm using my adaptation of IInterface, instead of IInterface directly).
I just depend on what IInterface has now staying the way it is, which is
a pretty safe bet, methinks.  ;)

Cheers,
Steve


More information about the Interface-dev mailing list