[Zope-dev] z3c.form and redirects
Martin Aspeli
optilude+lists at gmail.com
Tue Feb 23 09:33:31 EST 2010
Hi,
A lot of the forms I write perform a redirect at the end of the action
handler for a successfully submitted form.
z3c.form's __call__() indiscriminately calls update() and then render().
This means that even if something in update() (the action handler in
this case) causes a redirect, the render() method is called, which is
unnecessary since the browser will ignore the response body and perform
the redirect. It also triggered a small bug in Plone (since worked
around) whereby status messages would be output on the "hidden" page and
go missing for the final page (status messages in Plone can be persisted
across redirects using a cookie).
Grok's forms do something like this:
def __call__(self):
self.update()
if self.request.response.getStatus() not in (301, 302):
return self.render()
return u''
Would it be an idea for z3c.form to do the same?
Martin
--
Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book
More information about the Zope-Dev
mailing list