[Grok-dev] Re: grok.View: Self-submitting forms, redirect, and before()

Philipp von Weitershausen philipp at weitershausen.de
Fri Jan 12 13:08:51 EST 2007

Martijn Faassen wrote:
> Philipp von Weitershausen wrote:
>> Suresh V wrote:
>>> Christian Theune wrote:
>>>>>       def __call__(self):
>>>>> -        self.before()
>>>>> +        self.update()
>>>>> +        if self.request.response.getStatus() in (302, 303):
>>> Could the above be better dealt with as an exception? Who will be 
>>> setting this status?
>> You would be setting the status indirectly by 
>> response.redirect('some-other-place') within self.update(). You can 
>> also raise zope.publisher.interfaces.Redirect, but that needs no 
>> special handling as the exception will propagate all the way to the 
>> publisher anyway.
> Actually we got the .redirect() method in Grok so no 
> self.request.response.redirect() stuff necessary, just use 
> self.redirect() in your view code which talks to the response for you.

Right, that's very nice. All I'm saying is that the response status gets 
set to 302 or 303 when issuing a redirect w/o raising an exception.

http://worldcookery.com -- Professional Zope documentation and training
2nd edition of Web Component Development with Zope 3 is now shipping!

More information about the Grok-dev mailing list