[Checkins] SVN: grokcore.view/branches/1.13/ port the bugfix for accepting and passing on the status and redirect arguments to the redirect method

Jan-Wijbrand Kolman janwijbrand at gmail.com
Tue Jun 1 05:47:53 EDT 2010


Log message for revision 112880:
  port the bugfix for accepting and passing on the status and redirect arguments to the redirect method

Changed:
  U   grokcore.view/branches/1.13/CHANGES.txt
  U   grokcore.view/branches/1.13/setup.py
  U   grokcore.view/branches/1.13/src/grokcore/view/components.py
  U   grokcore.view/branches/1.13/src/grokcore/view/ftests/url/redirect.py

-=-
Modified: grokcore.view/branches/1.13/CHANGES.txt
===================================================================
--- grokcore.view/branches/1.13/CHANGES.txt	2010-06-01 09:42:11 UTC (rev 112879)
+++ grokcore.view/branches/1.13/CHANGES.txt	2010-06-01 09:47:53 UTC (rev 112880)
@@ -1,12 +1,12 @@
 Changes
 =======
 
-1.14.0 (unreleased)
+1.13.4 (unreleased)
 -------------------
 
-- None yet.
+- Fix the url() method to accept the "status" and "trusted" arguments, passed
+  on to the redirect method on the response object.
 
-
 1.13.3 (2010-05-27)
 -------------------
 

Modified: grokcore.view/branches/1.13/setup.py
===================================================================
--- grokcore.view/branches/1.13/setup.py	2010-06-01 09:42:11 UTC (rev 112879)
+++ grokcore.view/branches/1.13/setup.py	2010-06-01 09:47:53 UTC (rev 112880)
@@ -36,7 +36,7 @@
 
 setup(
     name='grokcore.view',
-    version = '1.14.0dev',
+    version = '1.13.4dev',
     author='Grok Team',
     author_email='grok-dev at zope.org',
     url='http://grok.zope.org',

Modified: grokcore.view/branches/1.13/src/grokcore/view/components.py
===================================================================
--- grokcore.view/branches/1.13/src/grokcore/view/components.py	2010-06-01 09:42:11 UTC (rev 112879)
+++ grokcore.view/branches/1.13/src/grokcore/view/components.py	2010-06-01 09:47:53 UTC (rev 112880)
@@ -45,8 +45,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/branches/1.13/src/grokcore/view/ftests/url/redirect.py
===================================================================
--- grokcore.view/branches/1.13/src/grokcore/view/ftests/url/redirect.py	2010-06-01 09:42:11 UTC (rev 112879)
+++ grokcore.view/branches/1.13/src/grokcore/view/ftests/url/redirect.py	2010-06-01 09:47:53 UTC (rev 112880)
@@ -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