Hi You need to pass a file object back, not a string.. So I just patched up your code to return a StringIO file object ( I have not tried it) import sys,os,string from OFS.Image import File import StringIO <======= def get_data: file=open('c:\test.txt','rb') data= StringIO(file.read()) <======= file.close() return data Probably you can pass the f'le object back as well but then somewhere you have to close it/ Regards Sedat -----Original Message----- From: Christophe Bec [mailto:christophe.bec@cgey.com] Sent: Monday, July 09, 2001 5:28 PM To: Sedat Yilmazer Subject: Re: [Zope] Upload a Zclass with a script ok i've tried this external method called get_data : get_data.py ___________________ ___________________ import sys,os,string from OFS.Image import File def get_data: file=open('c:\test.txt','rb') data=file.read() file.close() return data and when icall <dtml-var "REQUEST.set('file',<dtml-var get_data>)"> i 've an error thanks ----- Message d'origine ----- De : "Sedat Yilmazer" <sedat@kibele.com> À : "'Christophe Bec'" <cbec@capgemini.fr> Envoyé : lundi 9 juillet 2001 16:19 Objet : RE: [Zope] Upload a Zclass with a script IMHO reading a local file via DTML is not allowed. Best workaround is an external python method. You need to create a file object since most of the upload file managers look at the filename / content type etc. -----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Christophe Bec Sent: Monday, July 09, 2001 4:49 PM To: zope@zope.org Subject: [Zope] Upload a Zclass with a script Hi, I've a Zclass with "File" inheritance How can i do to upload a file with a script during instanciation (dtml or python) trying <dtml-var "REQUEST.set('file','c:\test.txt')"> gives me a instance, taking 'c:\test.txt' as a string and not as an object Thanks
participants (1)
-
Sedat Yilmazer