[Checkins] SVN: grokcore.view/trunk/ accept and pass on status and trusted arguments to the redirect method
Jan-Wijbrand Kolman
janwijbrand at gmail.com
Tue Jun 1 05:42:11 EDT 2010
Log message for revision 112879:
accept and pass on status and trusted arguments to the redirect method
Changed:
U grokcore.view/trunk/CHANGES.txt
U grokcore.view/trunk/src/grokcore/view/components.py
U grokcore.view/trunk/src/grokcore/view/ftests/url/redirect.py
-=-
Modified: grokcore.view/trunk/CHANGES.txt
===================================================================
--- grokcore.view/trunk/CHANGES.txt 2010-06-01 07:39:47 UTC (rev 112878)
+++ grokcore.view/trunk/CHANGES.txt 2010-06-01 09:42:11 UTC (rev 112879)
@@ -4,6 +4,9 @@
2.0 (unreleased)
----------------
+- Fix the url() method to accept the "status" and "trusted" arguments, passed
+ on to the redirect method on the response object.
+
- ``grokcore.view`` no longer depends on ``zope.app.testing`` and
related packages. Instead we now use ``zope.app.wsgi.testlayer`` to
run functional tests.
Modified: grokcore.view/trunk/src/grokcore/view/components.py
===================================================================
--- grokcore.view/trunk/src/grokcore/view/components.py 2010-06-01 07:39:47 UTC (rev 112878)
+++ grokcore.view/trunk/src/grokcore/view/components.py 2010-06-01 09:42:11 UTC (rev 112879)
@@ -46,8 +46,9 @@
def body(self):
return self.request.bodyStream.getCacheStream().read()
- def redirect(self, url):
- return self.request.response.redirect(url)
+ def redirect(self, url, status=None, trusted=False):
+ return self.request.response.redirect(
+ url, status=status, trusted=trusted)
def url(self, obj=None, name=None, data=None):
"""Return string for the URL based on the obj and name.
Modified: grokcore.view/trunk/src/grokcore/view/ftests/url/redirect.py
===================================================================
--- grokcore.view/trunk/src/grokcore/view/ftests/url/redirect.py 2010-06-01 07:39:47 UTC (rev 112878)
+++ grokcore.view/trunk/src/grokcore/view/ftests/url/redirect.py 2010-06-01 09:42:11 UTC (rev 112879)
@@ -12,7 +12,18 @@
>>> browser.open('http://localhost/manfred')
>>> browser.url
'http://localhost/manfred/another'
-
+
+ >>> browser.open('http://localhost/manfred/trustedredirect')
+ >>> browser.url
+ 'http://www.google.com/'
+
+ >>> browser.open('http://localhost/manfred/redirectwithstatus')
+ Traceback (most recent call last):
+ ...
+ HTTPError: HTTP Error 418: Unknown
+ >>> browser.url
+ 'http://localhost/manfred/redirectwithstatus'
+
"""
import grokcore.view as grok
@@ -23,7 +34,14 @@
def render(self):
self.redirect(self.url('another'))
+class TrustedRedirect(grok.View):
+ def render(self):
+ self.redirect('http://www.google.com/ncr', trusted=True)
+
+class RedirectWithStatus(grok.View):
+ def render(self):
+ self.redirect(self.url(), status=418)
+
class Another(grok.View):
def render(self):
return "Another view"
-
More information about the checkins
mailing list