Changeset 3048
- Timestamp:
- 06/01/06 15:47:34 (2 years ago)
- Files:
-
- django/trunk/django/core/validators.py (modified) (2 diffs)
- django/trunk/django/forms/__init__.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/core/validators.py
r3026 r3048 147 147 from cStringIO import StringIO 148 148 try: 149 Image.open(StringIO(field_data['content'])) 149 content = field_data['content'] 150 except TypeError: 151 raise ValidationError, gettext("No file was submitted. Check the encoding type on the form.") 152 try: 153 Image.open(StringIO(content)) 150 154 except IOError: # Python Imaging Library doesn't recognize it as an image 151 155 raise ValidationError, gettext("Upload a valid image. The file you uploaded was either not an image or a corrupted image.") … … 367 371 368 372 def __call__(self, field_data, all_data): 369 if self.min_size is not None and len(field_data['content']) < self.min_size: 373 try: 374 content = field_data['content'] 375 except TypeError: 376 raise ValidationError, gettext_lazy("No file was submitted. Check the encoding type on the form.") 377 if self.min_size is not None and len(content) < self.min_size: 370 378 raise ValidationError, self.min_error_message 371 if self.max_size is not None and len( field_data['content']) > self.max_size:379 if self.max_size is not None and len(content) > self.max_size: 372 380 raise ValidationError, self.max_error_message 373 381 django/trunk/django/forms/__init__.py
r3021 r3048 642 642 643 643 def isNonEmptyFile(self, field_data, all_data): 644 if not field_data['content']: 644 try: 645 content = field_data['content'] 646 except TypeError: 647 raise validators.CriticalValidationError, gettext("No file was submitted. Check the encoding type on the form.") 648 if not content: 645 649 raise validators.CriticalValidationError, gettext("The submitted file is empty.") 646 650
