[Twisted-web] HTTP redirection from data_*/render_* methods
    en.karpachov at ospaz.ru 
    en.karpachov at ospaz.ru
       
    Sat Jul 16 02:02:39 MDT 2005
    
    
  
On Fri, Jul 15, 2005 at 11:45:24AM -0700, Donovan Preston wrote:
> Even if you do raise an exception, all output generated up to that  
> point will have already been sent out over the socket to the browser.  
> This means the headers will already have been written, and  
> redirecting will have no effect.
It is why I set the buffered = True in my example.
> What you want instead is to set the "buffered" attribute of your Page  
> class to true before it starts rendering. This will cause nevow to  
> delay sending any output to the browser until the entire page is done  
> rendering, allowing you to do a redirect in the middle of it.
> 
> Personally, I don't think it's a good idea. You should decide about  
> the redirect up front, that way you avoid doing wasted work on the  
Well, one possible usage example could be
<table nevow:data="sqlquery" nevow:render="sequence">
  <tr nevow:pattern="item"><td>...</td></tr>
  <tr nevow:pattern="empty">
     <td nevow:render="redirect /notfound">None at all</td>
  </tr>
</table>
> server. Buffering also isn't as cool, because pages will chunk in  
> rather than streaming in.
> 
> Donovan
Thanks!
-- 
jk
    
    
More information about the Twisted-web
mailing list