You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Geoffrey Young <gy...@laserlink.net> on 2000/07/06 16:50:14 UTC

PerlAddVar bug

Sorry to bring up PerlAddVar again, but this time I have a legitimate bug.
It stems from what I reported last time about items in Apache::Table not
being visible outside a <Location> directives:

that is, given:

  Alias /test   /usr/local/apache/test
  # this outside value of foo doesn't get seen!
  # PerlSetVar here doesn't make a difference either
  PerlAddVar foo "outside"
  <Location /test>
     SetHandler perl-script
     PerlHandler Test::AddVar
     Order Allow,Deny
     Allow from All
     PerlSetupEnv Off
     PerlAddVar foo "one"
     PerlAddVar foo "two"
     PerlAddVar bar "bar"
     PerlAddVar foo "three"
  </Location>

package Test::AddVar;
use Apache::Constants qw( OK );
use strict;

sub handler {
    my $r = shift;
    $r->send_http_header("text/plain");
    my @foo = $r->dir_config->get('foo');
    print "get() foo\n";
    print join "\n", @foo;
    print "\ndo()\n";
    $r->dir_config->do( sub {
                         my($key, $value) = @_;
                         print("$key => $value\n");
                         1;
                      });

    print "done!";
    return OK;
}
1;

results:
get() foo
one
two
three
do()
foo => one
foo => two
bar => bar
foo => three
done!

-Geoff

Re: PerlAddVar bug

Posted by Rick Myers <ri...@sumthin.nu>.
On Jul 06, 2000 at 19:47:07 +0200, Eric Cholet twiddled the keys to say:
> > On Thu, 6 Jul 2000, Geoffrey Young wrote:
> > 
> > > Sorry to bring up PerlAddVar again, but this time I have a legitimate bug.
> > > It stems from what I reported last time about items in Apache::Table not
> > > being visible outside a <Location> directives:
> > 
> > See the section on DIR_MERGE in the Eagle book. It just needs someone to
> > write that code for PerlAddVar/PerlSetVar.
> > 
> 
> But there is dir_merge code for those variables, this works for me:
> 
> PerlSetVar MyVar foo
> 
> <Location /test/>
>   PerlSetVar MyVar bar
>   SetHandler "perl-script"
>   PerlHandler Apache::Registry
>   Options +ExecCGI
> </Location>
> 
> test/foo:
>   my $r = shift;
>   $r->send_http_header('text/plain');
>   print $r->dir_config('MyVar');
> 
> % GET http://localhost/test/foo
> bar
> 
> 
> I don't know about PerlAddVar, haven't tested Geoff's examples yet,
> but it should work as well since those vars all end up in 
> perl_dir_config->vars

This is the same problem I alluded to the other day in reply to Matt's
post concerning DIR_MERGE. In this example you're looking for MyVar
explicitly, which is found properly. In Geoffrey's example he is trying
to use $r->dir_config->do(), which will not see the global value for
some reason. His was the same setup I was using, with the same results.

Rick Myers                            rik@sumthin.nu
----------------------------------------------------
The Feynman Problem       1) Write down the problem.
Solving Algorithm         2) Think real hard.
                          3) Write down the answer.

Re: PerlAddVar bug

Posted by Eric Cholet <ch...@logilune.com>.
> On Thu, 6 Jul 2000, Geoffrey Young wrote:
> 
> > Sorry to bring up PerlAddVar again, but this time I have a legitimate bug.
> > It stems from what I reported last time about items in Apache::Table not
> > being visible outside a <Location> directives:
> 
> See the section on DIR_MERGE in the Eagle book. It just needs someone to
> write that code for PerlAddVar/PerlSetVar.
> 

But there is dir_merge code for those variables, this works for me:

PerlSetVar MyVar foo

<Location /test/>
  PerlSetVar MyVar bar
  SetHandler "perl-script"
  PerlHandler Apache::Registry
  Options +ExecCGI
</Location>

test/foo:
  my $r = shift;
  $r->send_http_header('text/plain');
  print $r->dir_config('MyVar');

% GET http://localhost/test/foo
bar


I don't know about PerlAddVar, haven't tested Geoff's examples yet,
but it should work as well since those vars all end up in 
perl_dir_config->vars

--
Eric



Re: PerlAddVar bug

Posted by Matt Sergeant <ma...@sergeant.org>.
On Thu, 6 Jul 2000, Geoffrey Young wrote:

> Sorry to bring up PerlAddVar again, but this time I have a legitimate bug.
> It stems from what I reported last time about items in Apache::Table not
> being visible outside a <Location> directives:

See the section on DIR_MERGE in the Eagle book. It just needs someone to
write that code for PerlAddVar/PerlSetVar.

-- 
<Matt/>

Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org | AxKit: http://axkit.org