I want to upload a File into a Folder under DTML control This code <dtml-call "manage_addFile(rep.this(),'newid',file)"> where rep is a folder, and file is from <input type='file' name='file'> produces this error Error Type: TypeError Error Value: argument 1: expected read-only character buffer, ImplicitAcquirerWrapper found Traceback (innermost last): <snip> File E:\opt\z\lib\python\DocumentTemplate\DT_Let.py, line 145, in render (Object: newid=get_new_id) File E:\opt\z\lib\python\DocumentTemplate\DT_Util.py, line 321, in eval (Object: manage_addFile(rep.this(),newid,file)) File <string>, line 0, in ? File E:\opt\z\lib\python\OFS\Image.py, line 115, in manage_addFile (Object: ElementWithAttributes) File E:\opt\z\lib\python\OFS\Image.py, line 169, in __init__ (Object: <Folder instance at 00FFD620>) File E:\opt\z\lib\python\OFS\Image.py, line 252, in _get_content_type (Object: <Folder instance at 00FFD620>) File E:\opt\z\lib\python\OFS\content_types.py, line 162, in guess_content_type (Object: ElementWithAttributes) File E:\opt\z\bin\lib\mimetypes.py, line 57, in guess_type (Object: ElementWithAttributes) File E:\opt\z\bin\lib\urllib.py, line 759, in splittype (Object: ElementWithAttributes) File E:\opt\z\bin\lib\re.py, line 119, in match TypeError: (see above) The part I don't understand is in OFS/Image.py, line 252 if type(body) is not type(''): body=body.data content_type, enc=guess_content_type( getattr(file, 'filename',id), body, content_type) return content_type What is this getattr() that takes three arguments? My guess is that id is the default value in case 'filename' is not found... no Id should be a string, not an ImplicitAquirerWrapper. I give up. I even tried to pass the content type explicitly too, but File.__init__() still tries to "guess" the content type. (why? I suppose mimetypes.guess_type() is smarter than the programmer/user <g>) Anyway. I don't care anymore *why* it doesn't work. I want to know what *will* work. I would prefer to use OFS.Image.File (a core component), but I am about ready to use the FileObject from Confera. Am I doing something terribly wrong?
participants (1)
-
Terrel Shumway