[Checkins] SVN: plone.z3cform/trunk/ avoid rendering the wrapped form if it redirecting while being updated

David Glick davidglick at onenw.org
Tue May 31 19:02:00 EDT 2011


Log message for revision 121856:
  avoid rendering the wrapped form if it redirecting while being updated

Changed:
  U   plone.z3cform/trunk/docs/HISTORY.txt
  U   plone.z3cform/trunk/plone/z3cform/layout.py

-=-
Modified: plone.z3cform/trunk/docs/HISTORY.txt
===================================================================
--- plone.z3cform/trunk/docs/HISTORY.txt	2011-05-31 15:11:14 UTC (rev 121855)
+++ plone.z3cform/trunk/docs/HISTORY.txt	2011-05-31 23:01:59 UTC (rev 121856)
@@ -4,6 +4,10 @@
 0.7.7 - unreleased
 ------------------
 
+* Avoid rendering a wrapped form if a redirect has already occurred after
+  updating it.
+  [davisagli]
+
 0.7.6 - 2011-05-17
 ------------------
 

Modified: plone.z3cform/trunk/plone/z3cform/layout.py
===================================================================
--- plone.z3cform/trunk/plone/z3cform/layout.py	2011-05-31 15:11:14 UTC (rev 121855)
+++ plone.z3cform/trunk/plone/z3cform/layout.py	2011-05-31 23:01:59 UTC (rev 121856)
@@ -52,7 +52,13 @@
 
         z2.switch_on(self, request_layer=self.request_layer)
         self.form_instance.update()
-        # A z3c.form.form.AddForm do a redirect in its render method.
+        
+        # If a form action redirected, don't render the wrapped form
+        if self.request.response.getStatus() in (302, 303):
+            self.contents = ""
+            return
+        
+        # A z3c.form.form.AddForm does a redirect in its render method.
         # So we have to render the form to see if we have a redirection.
         # In the case of redirection, we don't render the layout at all.
         self.contents = self.form_instance.render()



More information about the checkins mailing list