I stumbled upon a problem with Object schema field validation. The problem 
occurs, e.g., if the the Object field's schema itself contains a Choice field 
with a dynamically computed vocabulary. For the latter to validate correctly 
the field must be bound to the instance. But the Object field validation code 
in zope.schema._fields._validate_fields validates the attributes of the Object 
field instance without binding them first:

def _validate_fields(schema, value, errors=None):
                attribute = schema[name]
                if IField.providedBy(attribute):
                    # validate attributes that are fields
                    attribute.validate(getattr(value, name))
            except ValidationError, error:

Replacing the line

    attribute.validate(getattr(value, name))


    field = attribute.bind(value)
    field.validate(getattr(value, name))

fixes the problem.

Looks like a bug to me.

Markus Kemmerling
Zope-Dev maillist  -  Zope-Dev@zope.org
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope )

Reply via email to