[Zope3-dev] Important IFile bug!
Jim Fulton
jim at zope.com
Fri Jan 14 11:29:37 EST 2005
Roger Ineichen wrote:
...
> Ok, what can I do?
>
> Should I implement a IData field and enhance this field?
I think you should define an IMime schema that defines methods
to get and set the data. I suggest that this should be a
file-like interface, with, at least, read and write.
It should have a mime-type attribute and an encoding
attribute, for use with text.
Then you should define a mine field (IMImeField/MimeField)
for data with this interface.
Finally, you need a widget.
The widget should support:
- file-upload
- text area if content type is text/* *and* if an encoding
is specified.
- entry of content type and, for text types, the encoding
> The validate method of this field should allowes to store
> String and FileChunk? Others?
The validate method should accept strings and objects
with read methods.
> Is there a python lib for reading files and find the
> content type like stefan was implementing for images?
Of course, in the unlikely event that the client sends the
file type and/or encoding with the file upload, you should
use that information. Otherwise, use zope.app.content_types,
which seems to use the Python mimetypes module.
If you feel especially inspired, it would be nice to store
file-upload data in a session if someone submits a form
with a file-upload using other than the main submit
button or if there are validation errors on other fields.
IOW, it would be cool if the widget stored the data in a
session so that the data wasn't lost on a redisplay.
Jim
--
Jim Fulton mailto:jim at zope.com Python Powered!
CTO (540) 361-1714 http://www.python.org
Zope Corporation http://www.zope.com http://www.zope.org
More information about the Zope3-dev
mailing list