[cgiapp] cgiapp with Net::Server

Mark Fuller azfuller at gmail.com
Sun Mar 9 20:50:31 EDT 2008


Browsing the source for CGI.pm I noticed it calls
"initialize_globals()" when the class is loaded, but not when
instances are created. But, it does call it for each instance if the
mod_perl environment variable is set. (But, that does other things you
wouldn't want to do if you're not really using mod_perl). I also
noticed that it detects ActiveState's "PerlEx" (persistent Perl
utility) and calls "_reset_globals" which calls "initialize_globals".

I added a teardown method to Torsten's WebApp.pm and called
"$self->query()->initialize_globals()". The problem disappeared. (I
used teardown because that was the only place I could think to do it.
I guess a cgiapp_get_query would be more appropriate. Do the "new" and
then initialize_globals.).

So, it's definitely an issue with CGI.pm.  Apparently the params are
globals (class data). And, it doesn't have a catch-all "persistence"
flag. It has a flag for mod_perl. And, detects PerlEx. But, if you use
something else (like Net::Server's prefork) you're screwed.

CGI::Simple doesn't have this problem. The params aren't class data.
And, it calls initialize_globals with each instance (without going
through a bunch of questions about mod_perl or perlex). Reminds me why
I like CGI::Simple.

Mark


More information about the cgiapp mailing list