Re: [Catalyst] unbuffered output via multiple templates

2007-09-05 Thread Matt S Trout
On Thu, Aug 30, 2007 at 07:22:38PM -0600, Todd Harris wrote:
 Hi all -
 
 Quick introduction:  I'm new to Catalys, but I've been reading the
 mailing list online for some time.  I finally have a suitable project
 and have just started working on it.  The documentation on list so far
 have been a great help.
 
 My question:  I'd like to unbuffer output a la $|++.  I thought one
 approach might be to have a series of templates per page, rendering
 each sequentially, delivering each to the client in turn.
 
 So far I've come across two possible solutions: 1. SubRequest and 2.
 View::TT-render.
 
 But it seems that trapping the output of either and writing to STDOUT
 closes the request, such that only the first template is rendered and
 sent to the browser.

$c-finalize_headers;

foreach my $argset (@argsets) {
  $c-write($c-view($view_name)-render($template, $argset));
}

or code to that effect.

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

___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


[Catalyst] unbuffered output via multiple templates

2007-08-30 Thread Todd Harris
Hi all -

Quick introduction:  I'm new to Catalys, but I've been reading the
mailing list online for some time.  I finally have a suitable project
and have just started working on it.  The documentation on list so far
have been a great help.

My question:  I'd like to unbuffer output a la $|++.  I thought one
approach might be to have a series of templates per page, rendering
each sequentially, delivering each to the client in turn.

So far I've come across two possible solutions: 1. SubRequest and 2.
View::TT-render.

But it seems that trapping the output of either and writing to STDOUT
closes the request, such that only the first template is rendered and
sent to the browser.

Some pseudo code to illustrate:

sub myaction : Local {
  my $something = $c-subreq('/do_something',{ bar = $c-stash-{bar} });
  $c-res-body($text);
  $c-res-write($text);

  my $else = $c-subreq('/do_something_else',{ foo = $c-stash-{foo} });
  $c-res-body($else);
  $c-res-write($else);
}

sub do_something : Local {
   my ($self,$c) = @_;
   $c-stash-{load_em_up} = 'here we go';
}

Am I completely off track here?  I've used a monolithic template with
lots of includes but that is not exactly what I would like to
accomplish here.

Thanks in advance for suggestions.

Henri

___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/