Author: ianb
Date: 2008-05-14 10:07:05 -0600 (Wed, 14 May 2008)
New Revision: 3425

Modified:
   FormEncode/trunk/formencode/validators.py
Log:
Make FieldStorageUploadConverter handle empty values more gracefully

Modified: FormEncode/trunk/formencode/validators.py
===================================================================
--- FormEncode/trunk/formencode/validators.py   2008-05-14 15:43:45 UTC (rev 
3424)
+++ FormEncode/trunk/formencode/validators.py   2008-05-14 16:07:05 UTC (rev 
3425)
@@ -1695,12 +1695,17 @@
     """
     def _to_python(self, value, state=None):
         if isinstance(value, cgi.FieldStorage):
-            if value.filename:
+            if getattr(value, 'filename', None):
                 return value
             raise Invalid('invalid', value, state)
         else:
             return value 
 
+    def is_empty(self, value):
+        if isinstance(value, cgi.FieldStorage):
+            return bool(getattr(value, 'filename', None))
+        return FancyValidator.is_empty(self, value)
+
 class FileUploadKeeper(FancyValidator):
     """
     Takes two inputs (a dictionary with keys ``static`` and


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft 
Defy all challenges. Microsoft(R) Visual Studio 2008. 
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
FormEncode-CVS mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/formencode-cvs

Reply via email to