Ticket #1687: UploadSize.2.diff
File UploadSize.2.diff, 1.4 KB (added by , 19 years ago) |
---|
-
magic-removal/django/forms/__init__.py
636 636 #################### 637 637 638 638 class FileUploadField(FormField): 639 def __init__(self, field_name, is_required=False, validator_list=[]): 639 def __init__(self, field_name, is_required=False, validator_list=[], 640 length=None): 640 641 self.field_name, self.is_required = field_name, is_required 641 642 self.validator_list = [self.isNonEmptyFile] + validator_list 643 self.length = length 642 644 643 645 def isNonEmptyFile(self, field_data, all_data): 644 646 if not field_data['content']: 645 647 raise validators.CriticalValidationError, gettext("The submitted file is empty.") 646 648 647 649 def render(self, data): 648 return '<input type="file" id="%s" class="v%s" name="%s" />' % \ 649 (self.get_id(), self.__class__.__name__, self.field_name) 650 if self.length: 651 length = "size=\"%s\"" % str(self.length) 652 else: 653 length = "" 650 654 655 return '<input type="file" id="%s" class="v%s" %s name="%s" />' % \ 656 (self.get_id(), self.__class__.__name__, length, 657 self.field_name) 658 651 659 def html2python(data): 652 660 if data is None: 653 661 raise EmptyValue