[cgiapp] CAD::Server strangeness

Richard Jones ra.jones at dpw.clara.co.uk
Fri Sep 12 14:39:52 EDT 2008


George Hartzell wrote:
> Richard Jones writes:
>  > Using CGI::Application::Dispatch::Server, I'm getting a weird phenomenon 
>  > occurring:
> Can you provide a simplified test case that shows this behaviour, or
> share a copy of the app with me to walk into?
> 
> That output's being generated by CGI::Application::Dispatch, which is
> calling Data::Dumper:Dumper on the $args that are about to be passed
> to new().
> 
> It'd be interested to fire the server up under the perl debugger,
> break at that line, and see what's up with $args.

Hi George,

Well I've managed to narrow it down a bit - the problem was caused by 
defining the path/to/templates twice - once in TMPL_PATH => [ 
$path_to_templates ] in my Dispatch \%args_to_new hashref, and again in 
the webapp.cfg tt_config TEMPLATE_OPTIONS. As I can't avoid passing 
path/to/cfg in args_to_new, the fix is of course to omit TMPL_PATH.

I suspected this might be the case from the very simple demo app I put 
together for you (mailed separately), where I could see that the first 
request after server-start generated 2 '/path/to/templates' entries, the 
second request generated 4, third request generated 8, then 16, 32, etc. 
With my own app, the multiplication came much faster - the first request 
generated 8 '/path/to/templates' entries, second generated 64, and I 
didn't count the 3rd but would predict it was 512. There's probably a 
simple reason for this, but it's not that I've defined path/to/templates 
8 times in my App!

However, the curious thing is - afaict, there is only one definition of 
path/to/templates in the demo app (and that's in the Dispatcher not the 
WebApp), so I've mailed it to you so you can investigate the phenomenon. 
Failure to include TMPL_PATH in the demos' Dispatcher is fatal as the 
WebApp can't find the templates, confirming that there is only a single 
source of templates path info. My guess is that the problem lies in the 
definition of TMPL_PATH in args_to_new() in the Dispatcher rather than 
in the webapps' config file. I'd also take a guess that it's something 
pretty simple to trace if you're handy with perl -d.




More information about the cgiapp mailing list