[Catalyst] Problem with RenderView

Matt S Trout dbix-class at trout.me.uk
Mon May 7 14:56:58 GMT 2007


On Fri, May 04, 2007 at 12:34:01PM +0200, Bernhard Graf wrote:
> For a Catalyst application I have written View classes that serialize 
> DBIC ResultSets to common formats (CSV, XML) to be stored to disc.
> 
> Since the amount of data can become really big, the views don't set 
> $c->response->body(), but write the data directly in chunks using 
> $c->write().
> 
> The problem now is, that because $c->response->body() remains empty 
> C:A:RenderView still thinks it has to forward to the default view.
> As a result the Catalyst error page is appended to the (CSV/XML) output
> (Couldn't render template "file error - admin/data/dump: not found").
> 
> To come around this I use MyAction('RenderView') now, that
> <cite>
> return 1 if $c->response->{_finalized_headers};
> </cite>
> because finalize_headers() is called at the first call to $c->write().
> 
> Any problems with this approach (besides that it access' an internal 
> variable of Catalyst::Response)?
> 
> Could this be included in a future release of C:A:RenderView?

No, because it fixes -your- bug at the expense of breaking RenderView for
anybody who wants to send their headers early but still render a view.

Why can't you just set $c->stash(current_view => 'MyCSVView') and let
RenderView work its magic the normal way?

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director    Want a managed development or deployment platform?
Shadowcat Systems Ltd.   Contact mst (at) shadowcatsystems.co.uk for a quote
                                          http://www.shadowcatsystems.co.uk/ 



More information about the Catalyst mailing list