<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2769" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>I don't know why getContentType() doesn't exist
anymore?! a quick 'dir' of a file instance attributes
yields:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>['close', 'filename', 'fileno', 'flush', 'headers',
'isatty', 'read', 'readinto', 'readline', 'readlines', 'seek', 'tell',
'truncate', 'write', 'writelines', 'xreadlines']<BR></FONT></DIV>
<DIV><FONT face=Arial size=2>Anybody out there know what happened to
'getContentType'?</DIV></FONT>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>However, there is always a work around:
</FONT><FONT face=Arial
size=2>REQUEST['fname'].headers['Content-Type']</FONT></DIV>
<DIV><FONT face=Arial size=2>should get you what you want.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Jonathan</FONT></DIV>
<DIV><FONT face=Arial size=2> </DIV></FONT>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=mjakowlew@gmail.com href="mailto:mjakowlew@gmail.com">Mike
Jakowlew</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=zope@zope.org
href="mailto:zope@zope.org">zope@zope.org</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Tuesday, November 15, 2005 1:19
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> [Zope] Re: Problems using forms
to upload files to Zope</DIV>
<DIV><BR></DIV>Okay I corrected:<BR><BR><form action="uploadForm.py"
method="post" enctype="multipart/form-data"><BR><BR>and also tried the
getContentType, but I get the error:<BR><BR><STRONG
style="FONT-WEIGHT: normal">Error Type: AttributeError</STRONG><BR><STRONG
style="FONT-WEIGHT: normal">Error Value: FileUpload instance has no attribute
'getContentType'<SPAN
style="FONT-WEIGHT: bold"><BR></SPAN><BR>****uploadForm.py****<BR>def
content_type(self):<BR> return
self.getContentType()<BR><BR>def writeDB():<BR> # get sql
method<BR>
insert=container['insert_fileapps']<BR><BR>
REQUEST=context.REQUEST<BR> <BR>
department = REQUEST.form.get('department')<BR> title =
REQUEST.form.get ('title')<BR> filename =
REQUEST.form.get('upload_filename')<BR><BR> upload_contents=
content_type(filename)<BR><BR> if
content_type.find('image')!=-1:<BR>
context.manage_addImage(id, file, title)<BR> else:
<BR> context.manage_addFile(id,
file, title)<BR> return 'Finished'<BR><BR>
version = REQUEST.form.get('version')<BR> url =
REQUEST.form.get('url')<BR> ownerapp =
REQUEST.form.get('ownerapp')<BR> isoapp =
REQUEST.form.get('isoapp')<BR> comments =
REQUEST.form.get('comments')<BR> date =
REQUEST.form.get('date')<BR><BR>
filename=id<BR> filename =
filename.split('\\')[-1]<BR><BR> # call it, passing
arguments<BR> insert( department=department, title=title,
filename=filename, version=version, url=url, ownerapp=ownerapp, isoapp=isoapp,
comments=comments, date=date)<BR><BR> # return a
confirmation page<BR> page=container['thanks.html
']<BR> return
page()<BR><BR><BR>writeDB()<BR></STRONG><BR><BR>
<DIV><SPAN class=gmail_quote>On 11/15/05, <B class=gmail_sendername>Mike
Jakowlew</B> <<A
href="mailto:mjakowlew@gmail.com">mjakowlew@gmail.com</A>> wrote: </SPAN>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">Here's
what I'm trying to accomplish:<BR><BR>1. The user fills out a form page with
various fields <BR>2. The user selects a file to upload<BR>3. when the user
hits submit two things should happen:<BR> -
The file selected is uploaded <BR> - all the
filled out form fields are written to the database (MS SQL)<BR><BR>This is
my current problem:<BR>The writting to the database part works fine on it's
own, but when combined with the file upload I get this error <BR><BR><STRONG
style="FONT-WEIGHT: normal">Error Type: AttributeError</STRONG><BR><STRONG
style="FONT-WEIGHT: normal">Error Value: 'NoneType' object has no attribute
'headers'</STRONG><BR><BR><BR>My code:<BR><BR>*********HTML
FORM**********<BR><html><BR><h1
tal:content="template/title">title</h1> <BR><p>Fill out the
form below to update the website with the appropriate
info:</p><BR><BR><form action="uploadForm.py"><BR><table
width="100%" border="0" cellspacing="0" cellpadding="0"> <BR>
<tr><BR> <td width="16%" height="27"
align="right"><strong>Your Dept:
</strong></td><BR> <td
width="84%"><input type="text" name="department"></td>
<BR> </tr><BR> <tr><BR> <td
height="27" align="right"><strong>Document
Title:</strong></td><BR> <td><input
type="text" name="title"></td> <BR> </tr><BR>
<tr><BR> <td height="30"
align="right"><strong>Filename:</strong></td><BR>
<td><input type="file" name="upload_filename" ></td>
<BR> </tr><BR> <tr><BR> <td
height="28" align="right"><strong>Version of File
:</strong></td><BR> <td><input
type="text" name="version"></td> <BR> </tr><BR>
<tr><BR> <td height="28"
align="right"><strong>URL:</strong></td><BR>
<td><input type="text" name="url"></td> <BR>
</tr><BR> <tr><BR> <td height="33"
align="right"><strong>Owner
Approved:</strong></td><BR>
<td><input type="text" name="ownerapp"></td> <BR>
</tr><BR> <tr><BR> <td
align="right"><strong>ISO
Approved:</strong></td><BR>
<td><input type="text" name="isoapp"></td><BR>
</tr> <BR> <tr><BR> <td height="41"
align="right"><strong>Comments:
</strong></td><BR> <td
rowspan="2"><textarea name="comments" cols="60" rows="5">
<BR>
</textarea></td><BR> </tr><BR>
<tr><BR> <td height="85" align="right"
valign="top">&nbsp;</td><BR>
</tr><BR> <tr><BR> <td height="29"
align="right"><strong>Date</strong></td><BR>
<td><input type="text" name="date"></td><BR>
</tr><BR> <tr> <BR> <td height="62"
align="right"></td><BR>
<td><p><BR> <input
type="submit" id="submit" name="submit"
/><BR> <BR> </p>
<BR> </td><BR>
</tr><BR></table><BR><p><BR><BR></form><BR><hr><BR><p>Return
to the <a href="NewsTable">News
page</a></p><BR></html><BR><BR></BLOCKQUOTE></DIV>
<P>
<HR>
<P></P>_______________________________________________<BR>Zope maillist
-
Zope@zope.org<BR>http://mail.zope.org/mailman/listinfo/zope<BR>**
No cross posts or HTML encoding! **<BR>(Related lists -
<BR> http://mail.zope.org/mailman/listinfo/zope-announce<BR> http://mail.zope.org/mailman/listinfo/zope-dev
)<BR></BLOCKQUOTE></BODY></HTML>