[Zope-Checkins] CVS: Zope/lib/python/OFS - DTMLDocument.py:1.47 DTMLMethod.py:1.75 Image.py:1.137

Casey Duncan casey@zope.com
Fri, 12 Apr 2002 11:37:44 -0400


Update of /cvs-repository/Zope/lib/python/OFS
In directory cvs.zope.org:/tmp/cvs-serv9270/lib/python/OFS

Modified Files:
	DTMLDocument.py DTMLMethod.py Image.py 
Log Message:
FileUpload objects now eval false if filename is empty.
Upload buttons on DTML, Py Scripts, Files, Images and PTs raise an error
if the file is not specified instead of clearing the source (Bug #144)


=== Zope/lib/python/OFS/DTMLDocument.py 1.46 => 1.47 ===
             raise ResourceLockedError, (
                 'This document has been locked via WebDAV.')
-        if type(file) is not type(''): file=file.read()
+                
+        if type(file) is not type(''): 
+            if REQUEST and not file: 
+                raise ValueError, 'No file specified'
+            file=file.read()
+        
         self.munge(file)
         self.ZCacheable_invalidate()
         if REQUEST:


=== Zope/lib/python/OFS/DTMLMethod.py 1.74 => 1.75 ===
             raise ResourceLockedError, 'This DTML Method is locked via WebDAV'
 
-        if type(file) is not type(''): file=file.read()
+        if type(file) is not type(''): 
+            if REQUEST and not file: 
+                raise ValueError, 'No file specified'
+            file=file.read()
+            
         self.munge(file)
         self.ZCacheable_invalidate()
         if REQUEST:


=== Zope/lib/python/OFS/Image.py 1.136 => 1.137 ===
 from mimetools import choose_boundary
 from ZPublisher import HTTPRangeSupport
+from ZPublisher.HTTPRequest import FileUpload
 
 StringType=type('')
 manage_addFileForm=DTMLFile('dtml/imageAdd', globals(),Kind='File',kind='file')
@@ -437,6 +438,8 @@
             size=len(file)
             if size < n: return file, size
             return Pdata(file), size
+        elif isinstance(file, FileUpload) and not file:
+            raise ValueError, 'File not specified'
 
         if hasattr(file, '__class__') and file.__class__ is Pdata:
             size=len(file)