[Zope3-dev] Re: Field binding considered icky
Jim Fulton
jim at zope.com
Thu Apr 1 05:40:07 EST 2004
Garrett Smith wrote:
> Jim Fulton wrote:
>
>> I'm trying to catch up a bit on documentation. I'm working on
>> README.txt files for zope.interface and zope.component and will be
>> updating the README.txt for zope.schema.
>>
>> There is a "feature" of schema fields that I really don't want to
>> document. This feature is called "binding". A field can be "bound"
>> to an object. This creates a new field instance, which is a clone of
>> the original, that has a `context` attribute which is some object.
>> The object *may*, for example, be an object that has an attribute that
>> is specified by the field.
>
>
> Apart from being hackish (er...icky?), why does the current approach
> need to be revamped?
No other reason. I think that this is an important reason though for
something that is *so* foundational. The binding just feels very wrong.
I also want to merge zope.schema into zope.interface, so cleanliness is
even more important. Finally, I think that fields are are a special case
of attribute specifications. I think that interfaces need to provide a
uniform framework for defining interface attributes. Attribute
specifications need to fit in in a uniform way, so, for example, I want
the way fields get validated and the way methods get validated to be
similar.
>
>> We would get rid of the validate method of fields.
>>
>> When we want to validate a field, we'll adapt it *with* it's
>> context:
>>
>> >>> validator = getMultiAdapter((field, context), IValidator)
>> >>> validator.validate(value)
>>
>> A disadvantage of this approach is that it will require either
>> that:
>>
>> - We remove validation logic from zope.schema, or
>
>
> This doesn't seem like a disadvantage.
I agree that this has a positive side too.
... Other comments snipped.
Thanks for the comments
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 Zope3-dev
mailing list