[TransWarp] Proposing API changes to peak.binding, et al
Phillip J. Eby
pje at telecommunity.com
Tue Jun 17 18:33:57 EDT 2003
At 02:27 PM 6/17/03 -0400, Phillip J. Eby wrote:
>While doing this, I'd like to change the 'provides' keyword argument
>spelling. The term "provides" is now fairly well established as referring
>to what protocols/interfaces an object provides. But the 'provides'
>keyword doesn't declare what the attribute provides, it declares what
>configuration key(s) its component wants to publish it under, for the
>component and its subcomponents to use. Also, for historical reasons, the
>current mechanisms supporting this check to see if 'provides' is a tuple,
>and if so, iterate over it.
>
>I'd like to change the name to something that better describes its
>function, like 'publishForKeys', 'supplyAsKeys', or something like
>that. I'd also like to required that the value always be a sequence, so
>that introspection is unnecessary.
After discussion with Ty, the leading candidate for renaming provides is
now 'offerAs'. So code that currently reads, e.g.:
datamanager = binding.New(AliasDM, provides = ILDAPEntityDM)
color = binding.Constant(provides=PropertyName("myapp.color"),
value="red")
would need to change to:
datamanager = binding.New(AliasDM, offerAs = [ILDAPEntityDM])
color = binding.Constant(value="red", offerAs=["myapp.color"])
once I make the change. I don't have enough time left to implement this
today, so it'll go into effect tomorrow unless there are any strong
objections. (Note: the reason the "myapp.color" would no longer need to
have 'PropertyName()' around it is that 'offerAs' will adapt its inputs to
IConfigKey, thereby converting strings to property names. 'provides'
currently can't do this because of its special-case handling for tuples.)
The rationale for the new name is that the attribute is being "offered as"
an ILDAPEntityDM or "offered as" the "myapp.color" property. The fact that
the value of the attribute may also "provide" some interface IFoo does not
necessarily mean that it needs to be "offered" to other components that
seek such a configuration value.
More information about the PEAK
mailing list