Object schema field validation
Markus Kemmerling <[email protected]>
| Newsgroups | gmane.comp.web.zope.devel |
|---|---|
| Message-ID | <5035_1259492559_4B1254CF_5035_3506180_1_7C2E5C60-81A9-4DB0-A47F-C49B44D81E59@meduniwien.ac.at> |
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 - [email protected]
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 )