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): ... try: 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)) with field = attribute.bind(value) field.validate(getattr(value, name)) fixes the problem. Looks like a bug to me. Regards, Markus Kemmerling _______________________________________________ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )