Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Changed some Widget subclasses to be consistent about how they handle…

… the passed in 'attrs' parameter. We now always copy it (by calling the parent's __init__).

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6451 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 3c18331adc1fc45c9fec59991c1689cf751790e8 1 parent b1cc331
Malcolm Tredinnick authored October 04, 2007

Showing 1 changed file with 5 additions and 5 deletions. Show diff stats Hide diff stats

  1. 10  django/newforms/widgets.py
10  django/newforms/widgets.py
@@ -96,7 +96,7 @@ class PasswordInput(Input):
96 96
     input_type = 'password'
97 97
 
98 98
     def __init__(self, attrs=None, render_value=True):
99  
-        self.attrs = attrs or {}
  99
+        super(PasswordInput, self).__init__(attrs)
100 100
         self.render_value = render_value
101 101
 
102 102
     def render(self, name, value, attrs=None):
@@ -113,8 +113,8 @@ class MultipleHiddenInput(HiddenInput):
113 113
     of values.
114 114
     """
115 115
     def __init__(self, attrs=None, choices=()):
  116
+        super(MultipleHiddenInput, self).__init__(attrs)
116 117
         # choices can be any iterable
117  
-        self.attrs = attrs or {}
118 118
         self.choices = choices
119 119
 
120 120
     def render(self, name, value, attrs=None, choices=()):
@@ -153,9 +153,9 @@ def render(self, name, value, attrs=None):
153 153
 
154 154
 class CheckboxInput(Widget):
155 155
     def __init__(self, attrs=None, check_test=bool):
  156
+        super(CheckboxInput, self).__init__(attrs)
156 157
         # check_test is a callable that takes a value and returns True
157 158
         # if the checkbox should be checked for that value.
158  
-        self.attrs = attrs or {}
159 159
         self.check_test = check_test
160 160
 
161 161
     def render(self, name, value, attrs=None):
@@ -172,7 +172,7 @@ def render(self, name, value, attrs=None):
172 172
 
173 173
 class Select(Widget):
174 174
     def __init__(self, attrs=None, choices=()):
175  
-        self.attrs = attrs or {}
  175
+        super(Select, self).__init__(attrs)
176 176
         # choices can be any iterable, but we may need to render this widget
177 177
         # multiple times. Thus, collapse it into a list so it can be consumed
178 178
         # more than once.
@@ -211,8 +211,8 @@ def value_from_datadict(self, data, files, name):
211 211
 
212 212
 class SelectMultiple(Widget):
213 213
     def __init__(self, attrs=None, choices=()):
  214
+        super(SelectMultiple, self).__init__(attrs)
214 215
         # choices can be any iterable
215  
-        self.attrs = attrs or {}
216 216
         self.choices = choices
217 217
 
218 218
     def render(self, name, value, attrs=None, choices=()):

0 notes on commit 3c18331

Please sign in to comment.
Something went wrong with that request. Please try again.