From 3d9b12b2d893fb36a0e965519e7e9b4ed7e28c13 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Sun, 24 Dec 2006 03:36:49 +0000 Subject: [PATCH] newforms: Removed Widget.requires_data_list parameter, which was made redundant by Widget.value_from_datadict() git-svn-id: http://code.djangoproject.com/svn/django/trunk@4235 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/newforms/forms.py | 4 +--- django/newforms/widgets.py | 10 +++++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/django/newforms/forms.py b/django/newforms/forms.py index 44e5bf3d07..58d23e49e0 100644 --- a/django/newforms/forms.py +++ b/django/newforms/forms.py @@ -234,9 +234,7 @@ class BoundField(StrAndUnicode): def _data(self): "Returns the data for this BoundField, or None if it wasn't given." - if self.field.widget.requires_data_list and isinstance(self.form.data, MultiValueDict): - return self.form.data.getlist(self.html_name) - return self.form.data.get(self.html_name, None) + return self.field.widget.value_from_datadict(self.form.data, self.html_name) data = property(_data) def label_tag(self, contents=None): diff --git a/django/newforms/widgets.py b/django/newforms/widgets.py index ba11f35008..0dd0692e29 100644 --- a/django/newforms/widgets.py +++ b/django/newforms/widgets.py @@ -23,13 +23,18 @@ except NameError: flatatt = lambda attrs: u''.join([u' %s="%s"' % (k, escape(v)) for k, v in attrs.items()]) class Widget(object): - requires_data_list = False # Determines whether render()'s 'value' argument should be a list. is_hidden = False # Determines whether this corresponds to an . def __init__(self, attrs=None): self.attrs = attrs or {} - def render(self, name, value): + def render(self, name, value, attrs=None): + """ + Returns this Widget rendered as HTML, as a Unicode string. + + The 'value' given is not guaranteed to be valid input, so subclass + implementations should program defensively. + """ raise NotImplementedError def build_attrs(self, extra_attrs=None, **kwargs): @@ -130,7 +135,6 @@ class Select(Widget): return u'\n'.join(output) class SelectMultiple(Widget): - requires_data_list = True def __init__(self, attrs=None, choices=()): # choices can be any iterable self.attrs = attrs or {}