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
This commit is contained in:
Malcolm Tredinnick 2007-10-04 01:20:27 +00:00
parent b1cc3318c7
commit 3c18331adc
1 changed files with 5 additions and 5 deletions

View File

@ -96,7 +96,7 @@ class PasswordInput(Input):
input_type = 'password' input_type = 'password'
def __init__(self, attrs=None, render_value=True): def __init__(self, attrs=None, render_value=True):
self.attrs = attrs or {} super(PasswordInput, self).__init__(attrs)
self.render_value = render_value self.render_value = render_value
def render(self, name, value, attrs=None): def render(self, name, value, attrs=None):
@ -113,8 +113,8 @@ class MultipleHiddenInput(HiddenInput):
of values. of values.
""" """
def __init__(self, attrs=None, choices=()): def __init__(self, attrs=None, choices=()):
super(MultipleHiddenInput, self).__init__(attrs)
# choices can be any iterable # choices can be any iterable
self.attrs = attrs or {}
self.choices = choices self.choices = choices
def render(self, name, value, attrs=None, choices=()): def render(self, name, value, attrs=None, choices=()):
@ -153,9 +153,9 @@ class Textarea(Widget):
class CheckboxInput(Widget): class CheckboxInput(Widget):
def __init__(self, attrs=None, check_test=bool): def __init__(self, attrs=None, check_test=bool):
super(CheckboxInput, self).__init__(attrs)
# check_test is a callable that takes a value and returns True # check_test is a callable that takes a value and returns True
# if the checkbox should be checked for that value. # if the checkbox should be checked for that value.
self.attrs = attrs or {}
self.check_test = check_test self.check_test = check_test
def render(self, name, value, attrs=None): def render(self, name, value, attrs=None):
@ -172,7 +172,7 @@ class CheckboxInput(Widget):
class Select(Widget): class Select(Widget):
def __init__(self, attrs=None, choices=()): def __init__(self, attrs=None, choices=()):
self.attrs = attrs or {} super(Select, self).__init__(attrs)
# choices can be any iterable, but we may need to render this widget # choices can be any iterable, but we may need to render this widget
# multiple times. Thus, collapse it into a list so it can be consumed # multiple times. Thus, collapse it into a list so it can be consumed
# more than once. # more than once.
@ -211,8 +211,8 @@ class NullBooleanSelect(Select):
class SelectMultiple(Widget): class SelectMultiple(Widget):
def __init__(self, attrs=None, choices=()): def __init__(self, attrs=None, choices=()):
super(SelectMultiple, self).__init__(attrs)
# choices can be any iterable # choices can be any iterable
self.attrs = attrs or {}
self.choices = choices self.choices = choices
def render(self, name, value, attrs=None, choices=()): def render(self, name, value, attrs=None, choices=()):