On Thu, Oct 26, 2006 at 11:15:22PM -0500, Adrian Holovaty wrote:
> class Widget(object):
> def __init__(self, name, value, label=None, attrs=None):
> if value in EMPTY_VALUES: value = ''
> self.name, self.value, self.label = name, value, label
> self.attrs = attrs or {}
>
> def render(self):
> raise NotImplementedError
I'd rather remove value from __init__() and use render(self, data).
It's just a feeling, but it looks more appealing to me not to
put the data into the Widget object since I consider 'render' a function
of the value. Perhaps it would allow to instantiate the Widget earlier
and independently from actual rendering.
> class BoundField(object):
> "A Field plus data"
> def __init__(self, form, field, name):
> self._form = form
> self._field = field
> self._name = name
>
> def __str__(self):
> "Renders this field as an HTML widget."
> # Use the 'widget' attribute on the field to determine which type
> # of HTML widget to use.
> widget = self._field.widget(self._name,
> self._form.data.get(self._name, None))
> return widget.render()
so here the last 2 lines go
widget = self._field.widget(self._name)
return widget.render(self._form.data.get(self._name, None))
Perhaps I can make my point more clear when I have had more time to
think about it.
Michael
--
noris network AG - Deutschherrnstrasse 15-19 - D-90429 NÃŒrnberg -
Tel +49 911 9352-0 - Fax +49 911 9352-100
http://www.noris.de - The IT-Outsourcing Company
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-developers
-~----------~----~----~----~------~----~------~--~---