Thread: [htmltmpl] H::Template and CGI::Application
Brought to you by:
samtregar
From: Daniel A. <dan...@sn...> - 2004-10-14 13:18:37
|
Hello, I've been using HTML::Template for a while, but am having a weird problem when using it in a CGI::Application app. Basically, when I call $template->output, the application requests the page from the server twice, instead of once if I just create and return my own HMTL. CGI::Application is based around run modes, where calling http://localhost/myapp?rm=myrun will send you to a method in a class derived from CGI::Application. In the method I'm just getting some stuff from a database table, creating the template like this: $self->load_tmpl($template_file, case_sensitive => 1); and sending it back like this: return $template->output; # for CGI::Application or this: $self->page = $template->output; # for CGI::Application::Plus This is running under Apache 2.0.50 and mod_perl; HTML::Template 2.7; I've tried it under CGI::Application 1.30, CGI::Application::Plus 1.14, and CGI::Builder::CgiAppAPI v. 1.24 (all of these do basically the same thing). If I comment out the $template->output() call, the problem goes away: clicking on a like to the run-mode in question results in one call to that mode (but with no output); restoring the output() call results in two calls to the run mode. I've been reading various man pages but I'm still baffled. Anyone have an suggestions? Thanks for any help, Dan |
From: Thilo P. <thi...@we...> - 2004-10-15 03:45:33
|
Hi, > I've been using HTML::Template for a while, but am having a weird > problem when > using it in a CGI::Application app. Basically, when I call > $template->output, the application requests the page from the server > twice, > instead of once if I just create and return my own HMTL. Not sure what is happing here, but can you try the following: a) run it under plain CGI (not mod_perl) does it have the same problem? b) instead of return $tmpl->output; do $tmpl->output; return "no output" does it print "no output" now or the template + "no output"? Thilo |
From: Daniel A. <dan...@sn...> - 2004-10-15 13:05:27
|
> a) run it under plain CGI (not mod_perl) > does it have the same problem? Yes. > > b) instead of > return $tmpl->output; > do > > $tmpl->output; > return "no output" > > does it print "no output" now or the template + "no output"? In both mod_perl and CGI, it prints "no output" only. However, in both environments it's only bringing up the page once, not twice, the way it does when I do "return $tmpl->output" or "$self->page = $tmpl->output". There's nothing in the HTML to force a refresh, and I'm not sending back an extra header that I can see. Very strange. |
From: Mark S. <ma...@su...> - 2004-10-17 00:25:53
|
On 2004-10-14, Daniel Axtell <dan...@sn...> wrote: > Hello, > > I've been using HTML::Template for a while, but am having a weird problem when > using it in a CGI::Application app. Basically, when I call > $template->output, the application requests the page from the server twice, > instead of once if I just create and return my own HMTL. What do you mean by "the application requests the page from the server twice". Isn't the application /on/ the server? Do you mean the run mode is getting called twice? What are you monitoring to know that something is happening twice? This is indeed a strange issue, which doesn't immediately seem like a problem in H::T or the 3 CGI::App systems you tried. I would double check your application logic. If it still seems buggish, post a reduced case of the troublesome code, along with notes about how you able to see the duplicate request. Mark -- http://mark.stosberg.com/ |