i've held off for some time now on using the CGI::Application framework for building applications. recently i decided to take a good hard look at it and i can definately see some merit to the idea. so i decided to port a few of my apps to it. i've encountered a few problems.
the biggest one, that i'm hoping someone else might have some useful insight on is that under mod_perl, using CGI::Application seems to trigger problems with HTML::Template.
i have a class Foo that is instantiated during the setup() routine and the instance is stored using the param() mechanism. Foo does a bunch of useful things including producing HTML::Template instances with some common params already set. so the typical usage looks something like this:
sub some_runmode { my $self = shift; my $foo = $self->param('Foo'); my $template = $foo->template("some_template.tmpl"); # ... # do some stuff and pass other params to the template # ... return $template->output(); }
this runs fine in a plain CGI environment and in mod_perl when run in single process mode (httpd -X). in a regular, multi-process mod_perl environment though, it gets a little sketchy. about 50% of the time it will die with the following error:
Error executing run mode 'some_runmode'. Eval of code '$self->some_ru +nmode' resulted in error: HTML::Template->new() : Unknown or unmatche +d TMPL construct at templates/some_template.tmpl : line 1. at /usr/li +b/perl5/site_perl/5.8.0/HTML/Template.pm line 2130.
of course, the template file itself is fine (obviously, since it runs half the time and in non-mod_perl environments). it seems to be something to do with how CGI::Application plays with mod_perl and HTML::Template.
i haven't gone through the source for CGI::Application yet. is it just not written to work safely under mod_perl? i'm pretty confident in the Foo module and the rest of the code i wrote without CGI::Application; it's been running just fine under mod_perl for a while now. it just breaks when i convert it from a collection of seperate .pl files to a single CGI::Application module.
the other (more minor) pet peeve i have with CGI::Application is that it overrides $SIG{__DIE__} so exception handling with eval { die; } doesn't work. i can work around that though. it's the problems under mod_perl that are preventing me from adding it to my toolkit.
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |