Jeff Watkins wrote:
>
> I'd like to propose an alternative, which I'll code if necessary:
>
> class TableForm(Form):
> TextField("name")
> TextField("age", validators=Int())
>
> Then you can use:
>
> TableForm.widgets['name'] => the name TextField
> TableForm.widgets[1] => the age TextField
>
> This prevents name clashes. It preserves order. It feels good*.
>
But is this possible to do? otherwise seems like a nice solution, it's
also less magic since with the actual style:
age = TextField()
the TextField name attribute is *magically* initialized with "age" as
value, it's implicit and not explicit.
Anyway as Jorge said, one thing that would be nice to do is the ability
to prepare a set of widgets that you can import across your project,
for example:
class ConcatForm(Form):
template = ... (my own template)
...
TextField() <- O_o feels strange!
another possibility is combining your proposal with the fields one:
class fields:
TextField("name")
TextField("age", validators=Int())
Ciao
Michele
PS
In the end using classes in this way doesn't feel natural (but magic)
at least for me.
http://code.djangoproject.com/wiki/RemovingTheMagic