Author: bbangert
Date: 2006-06-03 09:51:26 -0600 (Sat, 03 Jun 2006)
New Revision: 1797
Modified:
FormEncode/trunk/formencode/validators.py
Log:
Fixing FieldStorage validator per bug report:
http://sourceforge.net/tracker/index.php?func=detail&aid=1464357&group_id=91231&atid=596416
Based on TurboGears version.
Modified: FormEncode/trunk/formencode/validators.py
===================================================================
--- FormEncode/trunk/formencode/validators.py 2006-06-03 15:44:34 UTC (rev 1796)
+++ FormEncode/trunk/formencode/validators.py 2006-06-03 15:51:26 UTC (rev 1797)
@@ -1424,17 +1424,18 @@
return result
class FieldStorageUploadConverter(FancyValidator):
-
"""
Converts a cgi.FieldStorage instance to
a value that FormEncode can use for file
uploads.
"""
- def _to_python(self, value, state):
+ def _to_python(self, value, state=None):
if isinstance(value, cgi.FieldStorage):
- return fieldstorage.convert_fieldstorage(value)
+ if value.filename:
+ return value
+ raise Invalid('invalid', value, state)
else:
- return value
+ return value
class FileUploadKeeper(FancyValidator):
"""
|