Changeset 4156
- Timestamp:
- 02/28/08 19:39:25 (9 months ago)
- Files:
-
- branches/1.1/turbogears/validators.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.1/turbogears/validators.py
r4106 r4156 21 21 22 22 from formencode import validators # to disambiguate the Number validator... 23 24 # this import is needed for our custom FieldStorageUploadConverter 25 import cgi 23 26 24 27 def _(s): return s # dummy … … 134 137 return value 135 138 139 # see #1464357 on FE bugtracker (http://tinyurl.com/lm9ae). 140 # Custom version of FieldStorage validator that does not break FE schema validator. 141 class FieldStorageUploadConverter(TgFancyValidator): 142 def __init__(self, *args, **kwargs): 143 super(TgFancyValidator, self).__init__(*args, **kwargs) 144 self.not_empty = kwargs.get('not_empty') 145 146 def _to_python(self, value, state=None): 147 if isinstance(value, cgi.FieldStorage): 148 if value.filename: 149 return value 150 if self.not_empty: 151 raise Invalid('invalid', value, state) 152 return value 136 153 137 154 # For translated messages that are not wrapped in a Validator.messages