[dancer-users] Delayed template processing

John J. McDermott, CPLP jjm at jkintl.com
Tue Oct 13 22:27:20 BST 2015


I'm trying to understand the issue here and what you want to do. Is it
correct that the issue is that you (Joerg and Amelia) want to /push/
data to the user in multiple chunks?

I do something similar with a push then a pull. I display the page with
a template that has the header, some data and a footer. On load the page
requests a different route through Dancer2 which populates the remaining
data. In my case if the route is myhost/page, the page template requests
myhost/pagedata (with appropriate parameters).

--john

On 10/13/2015 1:29 PM, Amelia Ireland wrote:
> I'd like to do the same thing. I haven't yet been able to identify at
> which point the streaming is failing (the browser? Apache proxy?
> Twiggy? Dancer?), and have been waiting to see if any of the Dancer2
> team will explain things further.
>
> In case it is helpful, there is some more information on PSGI and
> streaming in the Catalyst advent calendar here:
>
> http://www.catalystframework.org/calendar/2013/10 (four part series)
>
> and the PSGI FAQ has some information on streaming:
>
> https://metacpan.org/pod/PSGI::FAQ#What-if-I-want-to-stream-content-or-do-a-long-poll-Comet
>
> I haven't had a chance to do much research lately, but my next steps
> will be to find some other streaming PSGI apps to test (e.g. written
> with simple Plack, or some Catalyst or Mojolicious apps), to try to
> track down whether what we want to do is possible or whether the
> terminology is misleading.
>
>
> On 13 October 2015 at 06:51, Joerg Fallmann <fall at tbi.univie.ac.at
> <mailto:fall at tbi.univie.ac.at>> wrote:
>
>     Hi Everyone,
>
>     What I'm looking for is a way to render a template with part of
>     the results to the user to see while I continue processing and
>     when I'm done I want to show the final template with all results.
>     I'm currently using the new delayed method, which works fine for
>     strings,
>     but if I want to render templates it does not provide content
>     until the very end, so no in-between output is produced, as I
>     would like to show.
>     Example code here:
>
>     |get '/test/:*?' => sub { my $id = params->{'id'}; my $blub =
>     params->{'blub'}; delayed { my $tt = Template->new( {INCLUDE_PATH
>     => "$path", WRAPPER => 'layout.tt <http://layout.tt>', RELATIVE =>
>     1, }) || die "Template error: $Template::ERROR\n";
>     $tt->process('view.tt <http://view.tt>', { 'id' => $id, 'bla' =>
>     $blub }; content $tt; ### Process further push my @more, "String";
>     my $tt2 = Template->new( {INCLUDE_PATH => "$path", WRAPPER =>
>     'layout.tt <http://layout.tt>', RELATIVE => 1, }) || die "Template
>     error: $Template::ERROR\n"; $tt2->process('view.tt
>     <http://view.tt>', { 'id' => $id, 'bla' => $blub, 'more' => \@more
>     }; content $tt2; done; }; }; |
>
>     Is this possible or am I completely on the wrong track?
>     Thanks,
>     Joerg
>
>     Phone: +43 1 4277 52732
>
>     _______________________________________________
>     dancer-users mailing list
>     dancer-users at dancer.pm <mailto:dancer-users at dancer.pm>
>     http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
>
>
>
>
> _______________________________________________
> dancer-users mailing list
> dancer-users at dancer.pm
> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users

-- 
John J. McDermott, CPLP
Learning and Performance Consultant
jjm at jkintl.com 575/737-8556
Check out my security blog posts <http://cybersecurity.learningtree.com>
Add an A for the Arts To STEM and get STEAM and a strong engine to move
forward.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20151013/7dbf082f/attachment.html>


More information about the dancer-users mailing list