<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Janusz Zamecki wrote:
<blockquote cite="mid43DB39B5.90606@pipi.ma.cx" type="cite">
<pre wrap="">Hi, after googling and RTFM I have no other option but ask you for help.
I have the following DTML document:
<dtml-var standard_html_header>
<form action=3D"checkTheFile" method=3D"post" enctype=3D"multipart/form-d=
ata">
Select the file:
<input type=3D"file" name=3D"the_file">
<input type=3D"submit" name=3D"go" value=3D"Next >>">
</form>
<dtml-var standard_html_footer>
And here is the checkTheFile python script:
## Script (Python) "checkTheFile"
##bind container=3Dcontainer
##bind context=3Dcontext
##bind namespace=3D
##bind script=3Dscript
##bind subpath=3Dtraverse_subpath
##parameters=3D
##title=3D
##
# Import a standard function, and get the HTML request and response objec=
ts.
from Products.PythonScripts.standard import html_quote
request =3D container.REQUEST
RESPONSE =3D request.RESPONS
filename=3Dhtml_quote(request.form['the_file'].filename)
context.fs.rpt.manage_addFile(filename, request.form['the_file'],
content_type=3D"text/xml")
# the next line does'n work:
file_content=3Drequest.form['the_file'].read()
# EOF
I need to temporary save uploaded file then I have to validate it. But
I've received the following error message:
Site error:
Error Type: AttributeError
Error Value: read
I've tested it on zope 2.7.7 and 2.9.0 on suse 10.0. (python 2.4.1).
So, It is obvious to me that I've made a mistake, but I have no idea
where it is?
I hope that someone could show me the right way....
Best regards to all,
Janusz
</pre>
<pre wrap="">
<hr size="4" width="90%">
</pre>
</blockquote>
Janusz,<br>
<br>
Zope objects of meta-type FILE do not have a read(). But with python
there always is a way, eg<br>
<br>
ListOfLines = str(context.someFileObject).split('\n') # if its a
delimited file, this has worked for me in the past<br>
<br>
for line in listOfLines:<br>
doValidations(line)<br>
<br>
?<br>
David <br>
<br>
<br>
<br>
<br>
</body>
</html>