AW: [Zope-dev] z3c.form: unicode error with upload form
Roger Ineichen
dev at projekt01.ch
Wed Mar 5 18:56:06 EST 2008
Hi Christophe
> Betreff: [Zope-dev] z3c.form: unicode error with upload form
>
> Hi,
>
> The z3c.form.converter.FileUploadDataConverter has no
> toWidgetValue() method.
> Instead, it inherits from BaseDataConverter.toWidgetValue(),
> that returns unicode(data).
>
> However unicode(value) returns an error when the value is binary data!
>
> Shouldn't FileUploadDataConverter implement its own toWidgetValue?
I guess I know what you are trying to do.
As I implemented this widget I was thinking that a file upload never get
used for representation. Becaues it allways offers only upload again
if already an uploaded file exists.
And the converter is only designed for upload files and not for convert
them to widget output. Because the converter is registered for the
upload widget which never should represent the content.
This means you have to use a own widget for represent a file
content if it's text. And for this widget you can use another
custom converter. But sure I could be wrong. Do you see anything
which is wrong with that?
Now I guess, you are uesing the IFileWidget for your custom
widget implementation and this doesn't work, right?
See also my commit message in revision 76629:
----
Changed registration of file upload data converter.
Register FileUploadDataConverter for IBytes/IFileWidget.
This will force to use the data converter only for IFileWidget
and not for IBytes at all. IBytes/IWidget uses by default the
FieldDataConverter.
Added tests
Note:
The default widget for IBytes is the IFileWidget.
What does this mean:
If you need to use a text area widget for IBytes, you have to
register a custom widget in the form because the default widget
for IBytes is a file upload widget. You can do this by simply
set ``fields['foobar'].widgetFactory = TextWidget``.
-----
Does this make sense to you?
Any hintes and improvments are very welcome.
Regards
Roger Ineichen
> Christophe
More information about the Zope-Dev
mailing list