icook / yota

Flexible Python web forms with asynchronous validation
Other
33 stars 3 forks source link

Set mapper at form level #69

Open ericecook opened 11 years ago

ericecook commented 11 years ago

Some method of setting the mapper at a form level would be a big convenience, currently you have to overwrite the 'base' variable at every node. I'm looking at something like this:

login = EntryNode(
    base = "inline.html",
    css_class="input-small",
    label=False,
    placeholder="Username",
    validators=RequiredValidator())
password = PasswordNode(
    base = "inline.html",
    css_class="input-small",
    label=False,
    placeholder="Password",
    validators=RequiredValidator())
submit = SubmitNode(base = "inline.html", title="Login")
icook commented 11 years ago

Ah, initially this was intended to be done by changing the BaseNode attribute before generating the Form. IE BaseNode.base = '...'. This works but will change it for all things inheriting from base node, and is in general not a good solution. I'll think on the best way to solve this and try and come back to it.

icook commented 11 years ago

In it's current configuration this couldn't be accomplished without some metaclass voodoo. However, an easy alternative might be to use the global context, since that was basically what it was designed for, instead of inheritance. However that will add specificity to the Form class, meaning we should probably split Form into something like BaseForm, which is more abstract, and Form. This has been long overdue since Form has become more and more specific.

icook commented 11 years ago

Pushing to 0.3.1 to offload 0.2.3