Ticket #3489: sprint-patch1.diff
File sprint-patch1.diff, 2.5 KB (added by , 17 years ago) |
---|
-
django/newforms/fields.py
2 2 Field classes 3 3 """ 4 4 5 import copy 5 6 import datetime 6 7 import re 7 8 import time … … 100 101 """ 101 102 return {} 102 103 104 def __deepcopy__(self, memo): 105 result = copy.copy(self) 106 memo[id(self)] = result 107 result.widget = copy.deepcopy(self.widget, memo) 108 return result 109 103 110 class CharField(Field): 104 111 def __init__(self, max_length=None, min_length=None, *args, **kwargs): 105 112 self.max_length, self.min_length = max_length, min_length -
django/newforms/forms.py
31 31 dict.__init__(self, dict(data)) 32 32 33 33 def copy(self): 34 return SortedDictFromList([(k, copy. copy(v)) for k, v in self.items()])34 return SortedDictFromList([(k, copy.deepcopy(v)) for k, v in self.items()]) 35 35 36 36 class DeclarativeFieldsMetaclass(type): 37 37 """ -
tests/regressiontests/forms/tests.py
2681 2681 ... super(Person, self).__init__(*args, **kwargs) 2682 2682 ... if names_required: 2683 2683 ... self.fields['first_name'].required = True 2684 ... self.fields['first_name'].widget.attrs['class'] = 'required' 2684 2685 ... self.fields['last_name'].required = True 2686 ... self.fields['last_name'].widget.attrs['class'] = 'required' 2685 2687 >>> f = Person(names_required=False) 2686 2688 >>> f['first_name'].field.required, f['last_name'].field.required 2687 2689 (False, False) 2690 >>> f['first_name'].field.widget.attrs, f['last_name'].field.widget.attrs 2691 ({}, {}) 2688 2692 >>> f = Person(names_required=True) 2689 2693 >>> f['first_name'].field.required, f['last_name'].field.required 2690 2694 (True, True) 2695 >>> f['first_name'].field.widget.attrs, f['last_name'].field.widget.attrs 2696 ({'class': 'required'}, {'class': 'required'}) 2691 2697 >>> f = Person(names_required=False) 2692 2698 >>> f['first_name'].field.required, f['last_name'].field.required 2693 2699 (False, False) 2700 >>> f['first_name'].field.widget.attrs, f['last_name'].field.widget.attrs 2701 ({}, {}) 2694 2702 >>> class Person(Form): 2695 2703 ... first_name = CharField(max_length=30) 2696 2704 ... last_name = CharField(max_length=30)