You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by ColinB <cb...@yahoo.com> on 2003/07/28 11:40:44 UTC

Can't locate object method cgi_env

I'm trying to get some perl scripts that work OK under mod_perl 1
working in mod_perl 2. I'm therefore using the mod_perl 1 backward
compatiblity, and also the Apache::Registry from mod_perl 1 (as
described in the mod_perl 2 documentation to get around the chdir()
problem).

One of the scripts sets up a request handler, but when it tries to
execute:

$r->cgi_env(AB_AUTHHOST=>$host);

the following error appears in the httpd log file:

Can't locate object method "cgi_env" via package "Apache::RequestRec"
at /path/to/perl/lib/site_perl/Apache/MyModule.pm line 55

I have tried to search the perl.apache.org site for "cgi_env", but no
matches found.

I have also tried to search all of the files in the perl 5.8.0 and
mod_perl 2 distribution for occurences of cgi_env, and the ONLY place
it occurs is in "mod_perl-1.99_09/todo/deprecated_features.txt" which
lists several $r methods (including $r->cgi_env) and says that:

these features will either:
a) never be in 2.0
b) only be in if #ifdef MP_DEPRECATED
c) be in a form that was nothing like 1.xx
d) split off into something standalone on cpan


So if $r->cgi_env has been REMOVED from mod_perl 2, what is the
recommended alternative for it?

Thanks,

Colin


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

Re: Can't locate object method cgi_env

Posted by Stas Bekman <st...@stason.org>.
ColinB wrote:
> --- Stas Bekman <st...@stason.org> wrote:
> 
>>Stas Bekman wrote:
>>
>>>ColinB wrote:
>>>
>>>>One of the scripts sets up a request handler, but when it tries to
>>>>execute:
>>>>
>>>>$r->cgi_env(AB_AUTHHOST=>$host);
>>>
>>>
>>>I have never used that API, but I believe you misuse it. I think it
> 
> 
>>>should be:
>>>
>>>   $r->subprocess_env(AB_AUTHHOST=>$host);
>>>
>>>which works in mp1 and mp2.
> 
> 
> Thanks Stas. That seems to have fixed that problem.

Great.

>>I'm going to commit this (in case you don't want/can't
>>s/cgi_env/subprocess_env/)
>>----<snip>
> 
> 
> Thanks again. This is all pretty new to me and I'm not (yet) familiar
> with the procedures for submitting changes to source or documentation.

No worries, I've already updated the source and the docs.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Re: Can't locate object method cgi_env

Posted by ColinB <cb...@yahoo.com>.
--- Stas Bekman <st...@stason.org> wrote:
> Stas Bekman wrote:
> > ColinB wrote:
> >> One of the scripts sets up a request handler, but when it tries to
> >> execute:
> >>
> >> $r->cgi_env(AB_AUTHHOST=>$host);
> > 
> > 
> > I have never used that API, but I believe you misuse it. I think it

> > should be:
> > 
> >    $r->subprocess_env(AB_AUTHHOST=>$host);
> > 
> > which works in mp1 and mp2.

Thanks Stas. That seems to have fixed that problem.

> I'm going to commit this (in case you don't want/can't
> s/cgi_env/subprocess_env/)
> ----<snip>

Thanks again. This is all pretty new to me and I'm not (yet) familiar
with the procedures for submitting changes to source or documentation.

Colin


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

Re: Can't locate object method cgi_env

Posted by Stas Bekman <st...@stason.org>.
Stas Bekman wrote:
> ColinB wrote:
> 
>> I'm trying to get some perl scripts that work OK under mod_perl 1
>> working in mod_perl 2. I'm therefore using the mod_perl 1 backward
>> compatiblity, and also the Apache::Registry from mod_perl 1 (as
>> described in the mod_perl 2 documentation to get around the chdir()
>> problem).
>>
>> One of the scripts sets up a request handler, but when it tries to
>> execute:
>>
>> $r->cgi_env(AB_AUTHHOST=>$host);
> 
> 
> I have never used that API, but I believe you misuse it. I think it 
> should be:
> 
>    $r->subprocess_env(AB_AUTHHOST=>$host);
> 
> which works in mp1 and mp2.
> 
> cgi_env() is an alias to subprocess_env() in mp1, but it returns the env 
> vars in the list context.
> 
> I'll update the docs and Apache::compat shortly.

I'm going to commit this (in case you don't want/can't s/cgi_env/subprocess_env/)

Index: lib/Apache/compat.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/lib/Apache/compat.pm,v
retrieving revision 1.85
diff -u -r1.85 compat.pm
--- lib/Apache/compat.pm        11 Apr 2003 07:34:03 -0000      1.85
+++ lib/Apache/compat.pm        28 Jul 2003 10:22:10 -0000
@@ -401,6 +401,9 @@

  sub is_main { !shift->main }

+# really old back-compat methods, they shouldn't be used in mp1
+*cgi_var = *cgi_env = \&Apache::RequestRec::subprocess_env;
+
  package Apache::File;

  use Fcntl ();


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Re: Can't locate object method cgi_env

Posted by Stas Bekman <st...@stason.org>.
ColinB wrote:
> I'm trying to get some perl scripts that work OK under mod_perl 1
> working in mod_perl 2. I'm therefore using the mod_perl 1 backward
> compatiblity, and also the Apache::Registry from mod_perl 1 (as
> described in the mod_perl 2 documentation to get around the chdir()
> problem).
> 
> One of the scripts sets up a request handler, but when it tries to
> execute:
> 
> $r->cgi_env(AB_AUTHHOST=>$host);

I have never used that API, but I believe you misuse it. I think it should be:

    $r->subprocess_env(AB_AUTHHOST=>$host);

which works in mp1 and mp2.

cgi_env() is an alias to subprocess_env() in mp1, but it returns the env vars 
in the list context.

I'll update the docs and Apache::compat shortly.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com