You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by simran <si...@cse.unsw.edu.au> on 2002/07/29 01:05:29 UTC
$r->dir_config->(un)set issue...
Hi All,
I have a situation where it is convinent for me to define a global
"PerlSetVar" in my httpd.conf and then unset it for particular virtual
hosts.
I used to use the following configuration successfully:
----------------------------------------------------
httpd.conf
----------
<Perl>
use Apache::Server;
Apache->server->dir_config->unset("MyVar");
</Perl>
-----------------------------------------------------
That stopped working for me ever since we compiled
Apache/1.3.26 (Linix - Debian) with mod_perl/1.27
Has anyone else had the same issue?
On a similar note:
The following pices of code do not work:
-----------------------------------------------------
code sample 1
--------------
1. sub handler {
2. my $r = instance Apache::Request(shift);
3.
4. $r->dir_config(MyVar => undef);
5.
6. $r->dir_config->unset("MyVar");
7.
8. $r->dir_config->set(MyVar => undef);
9.
10. }
None of lines 4, 6 or 8 actually unset the variable.
A collegue tells me that if a "true" value (for the key MyVar) is not
passed to set then it ends up returning the value of MyVar - but then
how i want to set the value of MyVar to be false. I would have though
that unset/set would have specifically done what i told them to
unset/set rather than do fancy things with truth values...
Ideas anyone?
simran.
Re: $r->dir_config->(un)set issue...
Posted by Stas Bekman <st...@stason.org>.
simran wrote:
> Does that mean that
>
> $r->dir_config is not the same as $r->server->dir_config ?
not the same, $r->dir_config is a merge of the Location section setting
with Server/Vhost settings, $r->server->dir_config is only for
Server/Vhost settings.
__________________________________________________________________
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: $r->dir_config->(un)set issue...
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
>
> The following pices of code do not work:
>
> -----------------------------------------------------
> code sample 1
> --------------
>
> 1. sub handler {
> 2. my $r = instance Apache::Request(shift);
> 3.
> 4. $r->dir_config(MyVar => undef);
> 5.
> 6. $r->dir_config->unset("MyVar");
> 7.
> 8. $r->dir_config->set(MyVar => undef);
> 9.
> 10. }
>
>
> None of lines 4, 6 or 8 actually unset the variable.
did you try $r->server->dir_config->unset("MyVar") as well?
the dir_config table is a bit strange, since it merges per-server and
per-directory configurations at runtime - from what I remember when
playing with this last time, if you remove it from the per-dir config
but you set it on a per-server config (which sounds like what you are
doing) it will be perpetually re-populated on access to the per-dir
config. so, you may need to wipe both dir_config tables clean in
order to really unset the variable from your handler.
HTH
--Geoff
Re: $r->dir_config->(un)set issue...
Posted by simran <si...@cse.unsw.edu.au>.
On Wed, 2002-07-31 at 21:33, Geoffrey Young wrote:
>
>
> simran wrote:
>
> > Does that mean that
> >
> > $r->dir_config is not the same as $r->server->dir_config ?
> >
> > A PerlUnsetVar would indeed be very handy... as would PerlUnsetEnv :-)
>
> I looked into implementing that the last time it came up but IIRC it
> would take redoing the merge routines - from what I remember I got
> PerlUnsetVar to work at conf parse time, but it ended up being
> repopulated at request time when the directory merger ran (to merge
> $r->server->dir_config and $r->dir_config I think).
>
> calling unset() manually is probably your best bet.
>
I wouldn't mind using that, except that it does not work for me... (i
have copied a part of the original message below as that got snipped...)
I have a situation where it is convinent for me to define a global
"PerlSetVar" in my httpd.conf and then unset it for particular virtual
hosts.
I used to use the following configuration successfully:
----------------------------------------------------
httpd.conf
----------
<Perl>
use Apache::Server;
Apache->server->dir_config->unset("MyVar");
</Perl>
-----------------------------------------------------
That stopped working for me ever since we compiled
Apache/1.3.26 (Linix - Debian) with mod_perl/1.27
Has anyone else had the same issue?
On a similar note:
The following pices of code do not work:
-----------------------------------------------------
code sample 1
--------------
1. sub handler {
2. my $r = instance Apache::Request(shift);
3.
4. $r->dir_config(MyVar => undef);
5.
6. $r->dir_config->unset("MyVar");
7.
8. $r->dir_config->set(MyVar => undef);
9.
10. }
None of lines 4, 6 or 8 actually unset the variable.
A collegue tells me that if a "true" value (for the key MyVar) is not
passed to set then it ends up returning the value of MyVar - but then
how i want to set the value of MyVar to be false. I would have though
that unset/set would have specifically done what i told them to
unset/set rather than do fancy things with truth values...
Re: $r->dir_config->(un)set issue...
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
simran wrote:
> Does that mean that
>
> $r->dir_config is not the same as $r->server->dir_config ?
>
> A PerlUnsetVar would indeed be very handy... as would PerlUnsetEnv :-)
I looked into implementing that the last time it came up but IIRC it
would take redoing the merge routines - from what I remember I got
PerlUnsetVar to work at conf parse time, but it ended up being
repopulated at request time when the directory merger ran (to merge
$r->server->dir_config and $r->dir_config I think).
calling unset() manually is probably your best bet.
--Geoff
Re: $r->dir_config->(un)set issue...
Posted by simran <si...@cse.unsw.edu.au>.
Does that mean that
$r->dir_config is not the same as $r->server->dir_config ?
A PerlUnsetVar would indeed be very handy... as would PerlUnsetEnv :-)
On Wed, 2002-07-31 at 12:50, Stas Bekman wrote:
> s/$r->dir_config/$r->server->dir_config/?
>
> What's really needed is probably PerlUnSetEnv.
>
> simran wrote:
> > Hi All,
> >
> > I have a situation where it is convinent for me to define a global
> > "PerlSetVar" in my httpd.conf and then unset it for particular virtual
> > hosts.
> >
> > I used to use the following configuration successfully:
> >
> > ----------------------------------------------------
> > httpd.conf
> > ----------
> >
> > <Perl>
> > use Apache::Server;
> > Apache->server->dir_config->unset("MyVar");
> > </Perl>
> >
> > -----------------------------------------------------
> >
> > That stopped working for me ever since we compiled
> > Apache/1.3.26 (Linix - Debian) with mod_perl/1.27
> >
> >
> > Has anyone else had the same issue?
> >
> > On a similar note:
> >
> > The following pices of code do not work:
> >
> > -----------------------------------------------------
> > code sample 1
> > --------------
> >
> > 1. sub handler {
> > 2. my $r = instance Apache::Request(shift);
> > 3.
> > 4. $r->dir_config(MyVar => undef);
> > 5.
> > 6. $r->dir_config->unset("MyVar");
> > 7.
> > 8. $r->dir_config->set(MyVar => undef);
> > 9.
> > 10. }
>
> s/$r->dir_config/$r->server->dir_config/?
>
> What's really needed is probably PerlUnSetEnv.
>
> > None of lines 4, 6 or 8 actually unset the variable.
> >
> > A collegue tells me that if a "true" value (for the key MyVar) is not
> > passed to set then it ends up returning the value of MyVar - but then
> > how i want to set the value of MyVar to be false. I would have though
> > that unset/set would have specifically done what i told them to
> > unset/set rather than do fancy things with truth values...
> >
> > Ideas anyone?
> >
> > simran.
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
>
>
>
> --
>
>
> __________________________________________________________________
> 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: $r->dir_config->(un)set issue...
Posted by Stas Bekman <st...@stason.org>.
simran wrote:
> Hi All,
>
> I have a situation where it is convinent for me to define a global
> "PerlSetVar" in my httpd.conf and then unset it for particular virtual
> hosts.
>
> I used to use the following configuration successfully:
>
> ----------------------------------------------------
> httpd.conf
> ----------
>
> <Perl>
> use Apache::Server;
> Apache->server->dir_config->unset("MyVar");
> </Perl>
>
> -----------------------------------------------------
>
> That stopped working for me ever since we compiled
> Apache/1.3.26 (Linix - Debian) with mod_perl/1.27
>
>
> Has anyone else had the same issue?
>
> On a similar note:
>
> The following pices of code do not work:
>
> -----------------------------------------------------
> code sample 1
> --------------
>
> 1. sub handler {
> 2. my $r = instance Apache::Request(shift);
> 3.
> 4. $r->dir_config(MyVar => undef);
> 5.
> 6. $r->dir_config->unset("MyVar");
> 7.
> 8. $r->dir_config->set(MyVar => undef);
> 9.
> 10. }
s/$r->dir_config/$r->server->dir_config/?
What's really needed is probably PerlUnSetEnv.
> None of lines 4, 6 or 8 actually unset the variable.
>
> A collegue tells me that if a "true" value (for the key MyVar) is not
> passed to set then it ends up returning the value of MyVar - but then
> how i want to set the value of MyVar to be false. I would have though
> that unset/set would have specifically done what i told them to
> unset/set rather than do fancy things with truth values...
>
> Ideas anyone?
>
> simran.
>
>
>
>
>
>
>
>
>
>
>
>
--
__________________________________________________________________
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