Simon Belak wrote:
> Have you considered spiting your functionality into 2 methods as
> suggested (mostly for brevity sake) and adding a third (one being
> exposed and consequently determening the URL) to dispatch according to
> cherrypy.request.method:
>
> def some_page(self, *args, **kw):
>    if "POST" == cherrypy.request.method:
>      return self.some_page_submit(*args, **kw)
>    else:
>      return self.some_page_view(*args, **kw)

What do I do if some_page_submit decides that the values in **kw fail
validation and I need to post them back to some_page, along with (for
example) a dict of errors? I'm not entirely sure how to set up
some_page (or indeed the template it displays, including the form) to
work under both those conditions. Should it be something like this:

    @expose(html="myform")  # or whatever the syntax is... I forget
    def some_page(self, formdata=None, formerrors=None):
        if formdata is None:
            formdata = { name: "", address: "" }
        if formerrors is None:
            formerrors = {}
        return { data: formdata, errors: formerrors }

Forgive me if it seems lazy to not try this myself, but I'm not at my
development machine right now.

And how do I redirect to some_page from some_page_submit while passing
those 2 dicts across?

Thanks,

-- 
Ben Sizer


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to