Am 12.04.2009 um 15:12 schrieb Michael Howitz:
Hi,
I'm using a trunk version of z3c.form and have the following situation: In my interface I have a zope.schema.Bytes field. z3c.form.converter.FileUploadDataConverter.toFieldValue returns z3c.form.interfaces.NOT_CHANGED when I do not upload a file. z3c.form.validator.SimpleFieldValidator.validate fails later on as the value (z3c.form.interfaces.NOT_CHANGED) is not of type str (which is required by the Bytes field). I created a branch in svn to show the behavior. (z3c.form/branches/ icemac_validate_NOT_CHANGED)
I'm not sure how to fix this generally, some possible solutions come to my mind, but each idea has its own problems:
1) Create a special validator for zope.schema.Bytes + z3c.form.interfaces.IFileWidget which knows how to handle NOT_CHANGED. This does not seem to be a really general solution and might have the same problems like the following ideas.
2) When z3c.form.validator.SimpleFieldValidator.validate is called with NOT_CHANGED as value, try to look up the value on the context object. This fails on AddForms as the context there is the parent object.
3) When z3c.form.validator.SimpleFieldValidator.validate is called with NOT_CHANGED as value, do not validate hoping the previous value was valid. This approach fails with AddForms, too, when the Bytes field is required. (The missing-value-error does not get raised.)
Anyone having an idea for a possibly working solution?
As I got no responsed, I'd like to put this issue into z3c.form's bugtracker. But which is the correct one? https://bugs.launchpad.net/zope3/ ? Yours sincerely, -- Michael Howitz · mh@gocept.com · software developer gocept gmbh & co. kg · forsterstraße 29 · 06112 halle (saale) · germany http://gocept.com · tel +49 345 1229889 8 · fax +49 345 1229889 1 Zope and Plone consulting and development