[Zope-dev] Strange local(?) bug in uploading files
Peter Arvidsson
peter@innodev.com
Mon, 31 Jul 2000 18:55:41 +0200
I have a major problem with uploading files. I am doing a form to upload
PDF-files This is what it looks like (with only the relevant code):
pdf_form:
<form method="POST" action="pdf_method" enctype="multipart/form-data">
Title:<br>
<input type="text" size="70" name="titlepdf:required"><br>
PDF:<br>
<input type="file" size="58" name="pdf:required"><br>
<input type="submit" name="add" value="Next"><br>
</form>
pdf_method:
<dtml-call "REQUEST.set('ts', ZopeTime())">
<dtml-call "REQUEST.set('pdfid',_.str(_.int(ts)))">
<dtml-call expr="manage_addFile(pdfid, file=pdf, title=titlepdf)">
When I run this code in 2.1.6 it almost works. The content_type is wrong
but if you edit this property and set it to "application/pdf" it works.
(This is another strange problem.. this should be set automaticlly. I
doesnt work when I pass content_type='application/pdf' either.)
However when I try to run this in Zope 2.2 i get the following error
(with traceback):
Error Type: AttributeError
Error Value: seek
Traceback (innermost last):
File
/usr/local/new.test.version.of.zope.DO.NOT.REMOVE/lib/python/ZPublisher/Publish.py,
line 222, in publish_module
File
/usr/local/new.test.version.of.zope.DO.NOT.REMOVE/lib/python/ZPublisher/Publish.py,
line 187, in publish
File
/usr/local/new.test.version.of.zope.DO.NOT.REMOVE/lib/python/Zope/__init__.py,
line 221, in zpublisher_exception_hook
(Object: ElementWithAttributes)
File
/usr/local/new.test.version.of.zope.DO.NOT.REMOVE/lib/python/ZPublisher/Publish.py,
line 171, in publish
File
/usr/local/new.test.version.of.zope.DO.NOT.REMOVE/lib/python/ZPublisher/mapply.py,
line 160, in mapply
(Object: pdf_method)
File
/usr/local/new.test.version.of.zope.DO.NOT.REMOVE/lib/python/ZPublisher/Publish.py,
line 112, in call_object
(Object: pdf_method)
File
/usr/local/new.test.version.of.zope.DO.NOT.REMOVE/lib/python/OFS/DTMLMethod.py,
line 167, in __call__
(Object: pdf_method)
File
/usr/local/new.test.version.of.zope.DO.NOT.REMOVE/lib/python/DocumentTemplate/DT_String.py,
line 502, in __call__
(Object: pdf_method)
File /usr/local/zope/lib/python/DocumentTemplate/DT_Util.py, line 342,
in eval
(Object: manage_addFile(pdfid, file=pdf, title=titlepdf))
(Info: pdf)
File <string>, line 0, in ?
File
/usr/local/new.test.version.of.zope.DO.NOT.REMOVE/lib/python/OFS/Image.py,
line 125, in manage_addFile
(Object: ElementWithAttributes)
File
/usr/local/new.test.version.of.zope.DO.NOT.REMOVE/lib/python/OFS/Image.py,
line 271, in manage_upload
(Object: 965062238)
File
/usr/local/new.test.version.of.zope.DO.NOT.REMOVE/lib/python/OFS/Image.py,
line 304, in _read_data
(Object: 965062238)
AttributeError: (see above)
I tried to look in the python-files for manage_addFile but I didnt see
anything wrong there (however I am a python newbie :) Why do I get this
error in 2.2? I have tried everything and consulted the irc-channel but
noone could help me. Is this a bug in 2.2 or am I doing something wrong?