I just wanted to start a discussion about usage of CGIP in mod_perl environments. I am happy with CGIP's setup for my webhosting stuff, because we use plain CGI. However, for corporate work (should that day come), the fact that the engine slot and the prototype_enter method use autoloads to load Template and CGI would compromise performance: one would prefer that both of these be loaded eagerly.

So, since there is no class supplied with the CGIP distro by default which handles this (should there be?), I think the approach is obvious:

In the startup.pl or whatever pre-loaded handler you will use simply do
use Template;
use CGI;

use base qw(CGI::Prototype);

BEGIN { 

# _reset_globals is discussed here: http://use.perl.org/~merlyn/journal/24641
CGI::_reset_globals();
my $cgi = CGI->new

}

sub engine {
     my $self = shift;
     # no longer needed: require Template;
     Template->new($self->engine_config)
       or die "Creating tt: $Template::ERROR\n";
   });

sub CGI {
     $cgi
 });

Reply via email to