in reply to Re: Apache2 Frustrations
in thread Apache2 Frustrations

You can use CGI as long as you use Apache::compat.

Are you sure about this? According to the porting docs you can use CGI.pm with mod_perl2 as long as you use version 2.93 or greater.

CGI.pm is capable of taking the apache request object so it can deal with any mod_perl specific issues (like cleaning up globals) that need to be done. The more people that try it, the quicker it will be release quality.

my $r = Apache->request; my $query = CGI->new($r);

Note that to get access to the Apache->request object you may need to activate 'PerlOptions +GlobalRequest' in your apache config.

Also, the Apache::Request module for mod_perl2 is coming along nicely. Although it is not quite ready for production, I don't think it will be much longer.

- Cees

Replies are listed 'Best First'.
Re: Re: Re: Apache2 Frustrations
by !1 (Hermit) on Nov 22, 2003 at 02:45 UTC

    The only issue of which I am aware that had me use Apache::compat deals with CGI.pm's header subroutine. Since it uses $r->send_cgi_header. According to the docs, send_cgi_header is not available under mod_perl2. Am I incorrect in my interpretation? If so, I am quite sorry. If not then I apologize for not mentioning it earlier.

      It may have been a problem before, as in the early versions of mod_perl2 there were a lot of missing functions, but send_cgi_header is there now.

      cees@tim:~$ perl -MApache2 -MModPerl::MethodLookup -e print_method sen +d_cgi_header To use method 'send_cgi_header' add: use Apache::Response ();

      So it is definately available now. However, I just checked through the CGI.pm source and can't find any place where it loads Apache::Response. So there is a possibility that is won't work without that. And a quick check shows that it doesn't get brought in by any other Apache2 modules that CGI.pm does load...

      tim:~# MOD_PERL=1 perl -MApache2 -MCGI -e '$,=$/;print sort keys %INC; +' APR/Pool.pm APR/XSLoader.pm Apache/RequestRec.pm Apache/RequestUtil.pm Apache/XSLoader.pm Apache2.pm ...

      The reasons Apache::compat fixes the problem is because it automatically loads Apache::Response which makes cgi_send_header available again.

      So short of writing a bit of code that uses CGI.pm's header function under mod_perl2 and actually testing it, I guess you might be right... It might be best to ask this on the mod_perl list.

      Update: I wrote a quick script using the sample script at the top of the CGI.pm docs and ran it under mod_perl 1.99_11 successfully. So I guess we can let this worry to rest :)

      -Cees