[Checkins] SVN: five.grok/trunk/src/five/grok/ bug fix redirect
Christian Klinger
cvs-admin at zope.org
Wed Apr 25 11:07:30 UTC 2012
Log message for revision 125281:
bug fix redirect
Changed:
U five.grok/trunk/src/five/grok/components.py
A five.grok/trunk/src/five/grok/ftests/view/redirect.py
-=-
Modified: five.grok/trunk/src/five/grok/components.py
===================================================================
--- five.grok/trunk/src/five/grok/components.py 2012-04-24 19:22:20 UTC (rev 125280)
+++ five.grok/trunk/src/five/grok/components.py 2012-04-25 11:07:26 UTC (rev 125281)
@@ -79,6 +79,9 @@
# Set parent so that we have an acquisition chain
self.static.__parent__ = context
+ def redirect(self, url, status=302, trusted=False):
+ """ We don't need trusted in Zope2 """
+ self.request.response.redirect(url, status=status)
class ViewAwareZopePageTemplate(ZopePageTemplate):
Added: five.grok/trunk/src/five/grok/ftests/view/redirect.py
===================================================================
--- five.grok/trunk/src/five/grok/ftests/view/redirect.py (rev 0)
+++ five.grok/trunk/src/five/grok/ftests/view/redirect.py 2012-04-25 11:07:26 UTC (rev 125281)
@@ -0,0 +1,28 @@
+"""
+ >>> from five.grok.ftests.view.redirect import *
+ >>> id = getRootFolder()._setObject("manfred", Mammoth(id='manfred'))
+
+ >>> from Testing.testbrowser import Browser
+ >>> browser = Browser()
+ >>> browser.handleErrors = False
+ >>> browser.open("http://localhost/manfred/@@redirect")
+ >>> browser.url
+ 'http://localhost/manfred/@@newhome'
+"""
+from five import grok
+
+class Mammoth(grok.Model):
+ pass
+
+class Redirect(grok.View):
+ grok.context(Mammoth)
+
+ def render(self):
+ self.redirect('http://localhost/manfred/@@newhome')
+
+
+class NewHome(grok.View):
+ grok.context(Mammoth)
+
+ def render(self):
+ return "I am redirected to Here"
More information about the checkins
mailing list