Roger Ineichen wrote:
Knows sombody why the id is '' (empty) and the funktion not work?
I send a file with a form: ----------------------------- <form action="addFile" method="post" enctype="multipart/form-data"> <input type="file" name="file"> <input type="submit" value="upload"> </form>
To the python method: --------------------- def addFile(self,file): "This method adds a file" # create the file self.manage_addProduct['OFSP'].manage_addFile(id='', title='', file=file)
# redirect to main page return self.REQUEST.RESPONSE.redirect(index_html, url_quote(message)))
The error is: ------------- The id "" contains characters illegal in URLs.
<dtml-comment>----------------------------------------------------------- Edit load </dtml-comment> <tr><td><b>Load from File?</b></td></tr> <tr><td><form name="form" action="<dtml-var "URL1">/manage_load_file" method="POST" ENCTYPE="multipart/form-data"> <tr><td><INPUT TYPE="file" NAME="fid" SIZE="50" /><br> <input type="radio" name="ft" value='txt' checked /> as txt ( repr )<sup><b>*</b></sup> <input type="radio" name="ft" value='tbs' /> as tbs (pickle) <input type="submit" value=" Load " /> </td></tr> <tr><td></form> </td></tr> and def manage_load_file(self, ft, fid, REQUEST=None): """load tabstree from client file, ftype/format: 'tbs'=unpickle, 'txt'=eval""" f_type = ft # dunno how to detect filetype, made radio buttons file = REQUEST[ 'fid' ] if file == None: # code copied, dont understand it myself f_head = '' f_data = '' else: f_head = hasattr( file, "headers" ) and file.headers or None f_data = (f_head is None) and file or file.read() if f_type == 'tbs': # a) unpickle/pickle 3 lines tmpFile = StringIO(f_data) tmpPick = pickle.Unpickler(tmpFile) self.tabstree = [] # just to be safe self.tabstree = tmpPick.load() worked fine for me -- ------------------------------------------------------------- Who's got only a hammer sees the world as a nail hans augustin (software developer) hans@beehive.de beehive elektronische medien GmbH http://www.beehive.de phone: +49 30 847-82 0 fax: +49 30 847-82 299