Skip Menu |

This queue is for tickets about the Template-Provider-FromDATA CPAN distribution.

Report information
The Basics
Id: 25805
Status: resolved
Priority: 0/
Queue: Template-Provider-FromDATA

People
Owner: Nobody in particular
Requestors: NIKC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.06
Fixed in: (no value)



Just bumped in to an interesting interaction between T::P::FDATA and Proc::Daemon. Given this sequence of events: my $p = Template::Provider::FromDATA->new({ CLASSES => __PACKAGE__ }); ... Proc::Daemon::Init(); # Now running as a daemon ... my $t = Template->new({ LOAD_TEMPLATES => [ $p ], }); $t->process('template-name', { foo => bar }); __DATA__ __template-name__ My template [% foo %] no templates are found. I think this is because Proc::Daemon::Init() closes all open file handles (presumably, including DATA), so by the time the provider comes to read from DATA it can't. The solution is to call: $p->get_file(__PACKAGE__, 'template-name'); before the call to Proc::Daemon::Init() (repeating the get_file() call once for each template) so that the provider can load and cache them. It might be a good idea of T::P::FD checked to see if *DATA has been closed when it needs it, and re-opens it as necessary.
Subject: Re: [rt.cpan.org #25805]
Date: Mon, 26 Mar 2007 15:41:25 -0300
To: bug-Template-Provider-FromDATA [...] rt.cpan.org
From: "Brian Cassidy" <brian.cassidy [...] gmail.com>
Hi, On 3/26/07, via RT <bug-Template-Provider-FromDATA@rt.cpan.org> wrote: Show quoted text
> The solution is to call: > > $p->get_file(__PACKAGE__, 'template-name'); > > before the call to Proc::Daemon::Init() (repeating the get_file() call > once for each template) so that the provider can load and cache them. > It might be a good idea of T::P::FD checked to see if *DATA has been > closed when it needs it, and re-opens it as necessary.
I messed around for a bit but couldn't figure out a decent solution to the problem -- do you have a suitable patch you could provide? -Brian
I've added a PRELOAD option so that you can load all template data on initialization. I think this will help you get around your issue. Version 0.12 will hit CPAN soon.