Perrin Harkins wrote:

On Sun, 2004-09-19 at 17:10, Tosh Cooey wrote:

This all works fine under a normal Apache CGI environment, but once the script is running under ModPerl::Registry, or even ModPerl::PerlRun I am not getting the correct files served.

For example, www.site.com/view.pl?product=xyz might actually show me the result of www.site.com/view.pl?category=foo.


Your code probably has a closure in it somewhere.  For example, this
will break in any persistent environment (FastCGI, PerlEx, mod_perl,
etc.):

my $cgi = CGI->new();

do_something();

sub do_something {
    my $product = $cgi->param('product');
    print $product;
}


Yes and no.  The code looks like this:

use lots of modules;
exit(&main);
sub main {
        my $pageOBJ = Template->new({    ABSOLUTE => 1,
                START_TAG => quotemeta('[*'), END_TAG => quotemeta('*]') });
        my $in = new CGI;
        do stuff...
        my $cached_page = &getFilename($in);  # passing the CGI object
        do stuff...
        $pageOBJ->process($cached_page, $vars) || die $pageOBJ->error(), "\n";
}

sub getFilename {
        if requested file is old or not cached then (re)build the file
                my $pageOBJ = Template->new({ABSOLUTE => 1, OUTPUT => $file});
                do stuff...
                $pageOBJ->process($page, $vars) || die $pageOBJ->error(), "\n";
        }
        return $file;
}

So the code is fairly structured, and I can't see the "break" you mean, but I can see how that would cause a problem.

However I still think the fact that I have three Template objects open during the running of this script could be a problem.

But if it could be the CGI being a problem then perhaps the httpd.conf can help?

PerlSwitches -I/usr/local/lib/perl5/site_perl/5.8.0/i386-freebsd/Apache2
PerlOptions +SetupEnv
PerlModule Apache::compat
PerlModule Apache::DBI
PerlModule Apache::AuthDBI
PerlModule CGI
PerlInitHandler Apache::Reload
PerlSetVar ReloadAll Off
<VirtualHost CLIENT>
 <Directory /web/client>
  Options +ExecCGI
  PerlOptions +ParseHeaders
  <Files ~ "\.(pl)$">
   SetHandler perl-script
   PerlHandler ModPerl::PerlRun
  </Files>
 </Directory>
</VirtualHost>

Does loading CGI as a module cause problems? I read that it's actually a "slow" module to load, and so doing this helps speed it up.

Thank-you,

Tosh

--
McIntosh Cooey - Twelve Hundred Group LLC - http://www.1200group.com/

_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to