[Checkins] SVN: z3c.formui/trunk/ merged from 1.4 branch:
Michael Howitz
mh at gocept.com
Sat Mar 7 08:29:30 EST 2009
Log message for revision 97622:
merged from 1.4 branch:
- Don't do rendering in form's __call__ method when request is a
redirection.
- Reformatted long-description to render properly on pypi.
Changed:
U z3c.formui/trunk/CHANGES.txt
U z3c.formui/trunk/setup.py
U z3c.formui/trunk/src/z3c/formui/README.txt
U z3c.formui/trunk/src/z3c/formui/layout.py
-=-
Modified: z3c.formui/trunk/CHANGES.txt
===================================================================
--- z3c.formui/trunk/CHANGES.txt 2009-03-07 12:33:39 UTC (rev 97621)
+++ z3c.formui/trunk/CHANGES.txt 2009-03-07 13:29:29 UTC (rev 97622)
@@ -16,6 +16,14 @@
one doesn't work when we override a form template and use the form macro,
registered with this package.
+- Don't do rendering in form's __call__ method when request is a
+ redirection.
+
+- Added missing test dependency to ``z3c.ptcompat [test]``.
+
+- Reformatted long-description to render properly on pypi.
+
+
1.4.2 (2008-08-26)
------------------
Modified: z3c.formui/trunk/setup.py
===================================================================
--- z3c.formui/trunk/setup.py 2009-03-07 12:33:39 UTC (rev 97621)
+++ z3c.formui/trunk/setup.py 2009-03-07 13:29:29 UTC (rev 97622)
@@ -16,25 +16,21 @@
$Id$
"""
import os
-import xml.sax.saxutils
from setuptools import setup, find_packages
def read(*rnames):
- text = open(os.path.join(os.path.dirname(__file__), *rnames)).read()
- text = unicode(text, 'latin-1').encode('ascii', 'xmlcharrefreplace')
- return xml.sax.saxutils.escape(text)
+ return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
setup (
name='z3c.formui',
- version='1.4.3dev',
+ version='1.5.0dev',
author = "Stephan Richter, Roger Ineichen and the Zope Community",
author_email = "zope-dev at zope.org",
description = "A set of initial UI components for z3c.form.",
long_description=(
read('README.txt')
+ '\n\n' +
- 'Detailed Documentation\n'
- '**********************'
+ '.. contents::'
+ '\n\n' +
read('src', 'z3c', 'formui', 'README.txt')
+ '\n\n' +
Modified: z3c.formui/trunk/src/z3c/formui/README.txt
===================================================================
--- z3c.formui/trunk/src/z3c/formui/README.txt 2009-03-07 12:33:39 UTC (rev 97621)
+++ z3c.formui/trunk/src/z3c/formui/README.txt 2009-03-07 13:29:29 UTC (rev 97622)
@@ -473,8 +473,8 @@
Form Macros
-----------
-Load the confguration, which will make sure that all macros get registered
-correctly.
+Load the configuration, which will make sure that all macros get registered
+correctly:
>>> from zope.configuration import xmlconfig
>>> import zope.component
@@ -843,7 +843,30 @@
</div>
</div>
+Redirection
+-----------
+ The form doesn't bother rendering itself and its layout when
+ request is a redirection as the rendering doesn't make any sense with
+ browser requests in that case. Let's create a view that does a
+ redirection in its update method:
+
+ >>> class RedirectingView(PersonEditForm):
+ ... def update(self):
+ ... super(RedirectingView, self).update()
+ ... self.request.response.redirect('http://www.google.com/')
+
+ It will return an empty string when called as a browser page.
+
+ >>> redirectView = RedirectingView(person, divRequest)
+ >>> redirectView() == ''
+ True
+
+ However, the ``render`` method will render form's template as usual:
+
+ >>> '<div class="viewspace">' in redirectView.render()
+ True
+
Cleanup
-------
Modified: z3c.formui/trunk/src/z3c/formui/layout.py
===================================================================
--- z3c.formui/trunk/src/z3c/formui/layout.py 2009-03-07 12:33:39 UTC (rev 97621)
+++ z3c.formui/trunk/src/z3c/formui/layout.py 2009-03-07 13:29:29 UTC (rev 97622)
@@ -1,6 +1,6 @@
##############################################################################
#
-# Copyright (c) 2007 Zope Foundation and Contributors.
+# Copyright (c) 2007-2009 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
@@ -21,6 +21,9 @@
from z3c.template.interfaces import ILayoutTemplate
+REDIRECT_STATUS_CODES = (301, 302, 303)
+
+
class FormLayoutSupport(object):
"""Layout support for forms except IAddForm."""
@@ -28,6 +31,11 @@
def __call__(self):
self.update()
+
+ if self.request.response.getStatus() in REDIRECT_STATUS_CODES:
+ # don't bother rendering when redirecting
+ return ''
+
if self.layout is None:
layout = zope.component.getMultiAdapter((self, self.request),
ILayoutTemplate)
@@ -45,6 +53,7 @@
if self._finishedAdd:
self.request.response.redirect(self.nextURL())
return ''
+
if self.layout is None:
layout = zope.component.getMultiAdapter((self, self.request),
ILayoutTemplate)
More information about the Checkins
mailing list