On Tuesday 07 April 2009 17:46:52 Mark Ramm wrote:
> No objection from me.   2.1 lives in hg now, and the dispatch refactor
> is something that I want to push forward sooner rather than later, so
> it may not be long between 2.0 and 2.1.
>
> Granting you push access to that repo now. ;)

Great, thank you very much.

I just found out that there is another way of doing this though, so with 
Timur's advice about callable being a bit problematic, I could add that to 
the documentation as a recipe. 

It looks like this:


#=============================================================================

class FormA(ListForm):

    class fields(WidgetsList):
        kind = HiddenField(default="form_a")
        first = TextField(validator=Int(not_empty=True))
        second = TextField(validator=Int(not_empty=True))


#=============================================================================

class FormB(ListForm):

    class fields(WidgetsList):
        kind = HiddenField(default="form_b")
        first = TextField(validator=Int(not_empty=True))
        second = TextField(validator=Int(not_empty=True))


form_a = FormA(action="validate_multiple_forms")
form_b = FormB(action="validate_multiple_forms")


#=============================================================================

class FormGetter(object):
    def validate(self, values, state):
        return dict(form_a=form_a,
                    form_b=form_b)[values["kind"]].validate(values, state)


#=============================================================================

class FormsController(SecureController):

    
@expose("ableton.next.controllers.internal.best_practices.templates.forms_index")
    @with_trailing_slash
    def index(self):
        return {}


    
@expose("ableton.next.controllers.internal.best_practices.templates.multiple_forms")
    def multiple_forms(self, kind=None, **kwargs):
        """
        """
        if kind is None or kind == "form_a":
            form = form_a
        else:
            form = form_b
        c.form = form
        return dict()


    @expose()
    @validate(form=FormGetter(), error_handler=multiple_forms)
    def validate_multiple_forms(self, **kwargs):
        return str(kwargs)



Diez

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears Trunk" 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/turbogears-trunk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to