[Checkins] SVN: plone.z3cform/trunk/ A z3c.form.form.AddForm do a redirect in its render method.

Vincent Fretin vincent.fretin at gmail.com
Mon Jan 25 12:57:01 EST 2010


Log message for revision 108486:
  A z3c.form.form.AddForm do 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.
  This version remove the contents method on FormWrapper,
  it's now an attribute.
  

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

-=-
Modified: plone.z3cform/trunk/docs/HISTORY.txt
===================================================================
--- plone.z3cform/trunk/docs/HISTORY.txt	2010-01-25 17:44:07 UTC (rev 108485)
+++ plone.z3cform/trunk/docs/HISTORY.txt	2010-01-25 17:57:01 UTC (rev 108486)
@@ -1,6 +1,16 @@
 Changelog
 =========
 
+0.5.10 - unreleased
+-------------------
+
+* A z3c.form.form.AddForm do 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.
+  This version remove the contents method on FormWrapper,
+  it's now an attribute.
+  [vincentfretin]
+
 0.5.9 - 2010-01-08
 ------------------
 

Modified: plone.z3cform/trunk/plone/z3cform/interfaces.py
===================================================================
--- plone.z3cform/trunk/plone/z3cform/interfaces.py	2010-01-25 17:44:07 UTC (rev 108485)
+++ plone.z3cform/trunk/plone/z3cform/interfaces.py	2010-01-25 17:57:01 UTC (rev 108486)
@@ -16,10 +16,6 @@
         """We use the content provider update/render couple.
         """
     
-    def contents():
-        """Renders the wrapped form.
-        """
-
     form = Attribute("The form class. Should be set at class level")
     
     form_instance = schema.Object(

Modified: plone.z3cform/trunk/plone/z3cform/layout.py
===================================================================
--- plone.z3cform/trunk/plone/z3cform/layout.py	2010-01-25 17:44:07 UTC (rev 108485)
+++ plone.z3cform/trunk/plone/z3cform/layout.py	2010-01-25 17:57:01 UTC (rev 108486)
@@ -55,18 +55,9 @@
         """
         self.update()
         if self.request.response.getStatus() in (302, 303):
-            return
+            return u""
         return self.render()
 
-    def contents(self):
-        """This method renders the wrapped form using its render method.
-        Note that this method does *not* check the redirection. The form
-        will be rendered as if nothing happened.
-
-        Override this method if you have more than one form.
-        """
-        return self.form_instance.render()
-
     def render(self):
         """This method renders the outer skeleton template, which in
         turn calls the 'contents' method below.
@@ -76,6 +67,12 @@
         directive. If no index template is set, we look up a an adapter from
         (self, request) to IPageTemplate and use that instead.
         """
+        # A z3c.form.form.AddForm do 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()
+        if self.request.response.getStatus() in (302, 303):
+            return u""
         if self.index is None:
             template = zope.component.getMultiAdapter(
                 (self, self.request), IPageTemplate)



More information about the checkins mailing list