Mailing List Archive

RE: cvs commit: modperl/Apache Apache.pm
a PerlSetVar foo following a PerlAddVar foo is supposed to reset the value
of foo, clearing the previous array (IIRC)

might be worth noting...

also, once you use the Apache::Table interface for either, you can call
set() in addition to add(). Doug thought that this might only set it for
the lifetime of the child, not permanently. I haven't verified this either
way (only that it works for my needs :)

--Geoff

> -----Original Message-----
> From: sbekman@locus.apache.org [mailto:sbekman@locus.apache.org]
> Sent: Saturday, November 25, 2000 10:39 AM
> To: modperl-cvs@apache.org
> Subject: cvs commit: modperl/Apache Apache.pm
>
>
> sbekman 00/11/25 07:39:25
>
> Modified: . Changes mod_perl.pod
> Apache Apache.pm
> Log:
> Documenting the new PerlAddVar httpd.conf directive. Please
> verify that I
> didn't do any mistakes since I've added this from my notes
> made about 6
> months ago. Thanks.
>
> Revision Changes Path
> 1.549 +3 -0 modperl/Changes
>
> Index: Changes
> ===================================================================
> RCS file: /home/cvs/modperl/Changes,v
> retrieving revision 1.548
> retrieving revision 1.549
> diff -u -r1.548 -r1.549
> --- Changes 2000/11/07 23:09:19 1.548
> +++ Changes 2000/11/25 15:39:21 1.549
> @@ -10,6 +10,9 @@
>
> =item 1.24_02-dev
>
> +Documenting the new PerlAddVar httpd.conf directive
> +[Stas Bekman <sbekman@stason.org>]
> +
> new Apache::test::static_modules() method
> [Ken Williams <ken@forum.swarthmore.edu>]
>
>
>
>
> 1.21 +28 -5 modperl/mod_perl.pod
>
> Index: mod_perl.pod
> ===================================================================
> RCS file: /home/cvs/modperl/mod_perl.pod,v
> retrieving revision 1.20
> retrieving revision 1.21
> diff -u -r1.20 -r1.21
> --- mod_perl.pod 2000/03/05 23:46:30 1.20
> +++ mod_perl.pod 2000/11/25 15:39:22 1.21
> @@ -167,15 +167,38 @@
>
> =item CONFIGURATION
>
> -The C<PerlSetVar> directive provides a simple mechanism for passing
> -information from configuration files to Perl modules or
> Registry scripts:
> +The C<PerlSetVar> and C<PerlAddVar> directives provide a simple
> +mechanism for passing information from configuration files to Perl
> +modules or Registry scripts.
>
> +The C<PerlSetVar> directive allows you to set a key/value pair.
> +
> PerlSetVar SomeKey SomeValue
>
> Perl modules or scripts retrieve configuration values using the
> -C<$r-E<gt>dir_config> method (see 'perldoc Apache').
> +C<$r-E<gt>dir_config> method.
> +
> + $SomeValue = $r->dir_config('SomeKey');
> +
> +The C<PerlAddVar> directive allows you to emulate Perl arrays:
> +
> + PerlAddVar SomeKey FirstValue
> + PerlAddVar SomeKey SecondValue
> + ... ... ...
> + PerlAddVar SomeKey Nth-Value
> +
> +In the Perl modules the values are extracted using the
> +C<$r-E<gt>dir_config-E<gt>get> method.
> +
> + @array = $r->dir_config->get('SomeKey');
> +
> +Alternatively in your code you can extend the setting with:
> +
> + $r->dir_config->add(SomeKey => 'Bar');
> +
> +C<PerlSetVar> and C<PerlAddVar> handle keys case-insensitively.
> +
>
> -C<PerlSetVar> handles keys case-insensitively.
>
> =item GATEWAY_INTERFACE
>
> @@ -790,7 +813,7 @@
>
> =head1 REVISION
>
> -$Id: mod_perl.pod,v 1.20 2000/03/05 23:46:30 dougm Exp $
> +$Id: mod_perl.pod,v 1.21 2000/11/25 15:39:22 sbekman Exp $
>
> =head1 AUTHOR
>
>
>
>
> 1.59 +23 -0 modperl/Apache/Apache.pm
>
> Index: Apache.pm
> ===================================================================
> RCS file: /home/cvs/modperl/Apache/Apache.pm,v
> retrieving revision 1.58
> retrieving revision 1.59
> diff -u -r1.58 -r1.59
> --- Apache.pm 2000/11/07 23:09:25 1.58
> +++ Apache.pm 2000/11/25 15:39:24 1.59
> @@ -589,6 +589,29 @@
> I<Apache::Table> class when called in a scalar context with no
> "key" argument. See I<Apache::Table>.
>
> +
> +=item $r->dir_config->get( $key )
> +
> +Returns the value of a per-directory array variable
> specified by the
> +C<PerlAddVar> directive.
> +
> + # <Location /foo/bar>
> + # PerlAddVar Key Value1
> + # PerlAddVar Key Value2
> + # </Location>
> +
> + my @val = $r->dir_config->get('Key');
> +
> +Alternatively in your code you can extend the setting with:
> +
> + $r->dir_config->add(Key => 'Value3');
> +
> +Keys are case-insensitive.
> +
> +Will return a I<HASH> reference blessed into the
> +I<Apache::Table> class when called in a scalar context with no
> +"key" argument. See I<Apache::Table>.
> +
> =item $r->requires
>
> Returns an array reference of hash references, containing
> information
>
>
>
>
RE: cvs commit: modperl/Apache Apache.pm [ In reply to ]
> -----Original Message-----
> From: Stas Bekman [mailto:stas@stason.org]
> Sent: Monday, November 27, 2000 10:56 AM
> To: Geoffrey Young
> Subject: RE: cvs commit: modperl/Apache Apache.pm
>
>
> > ok... I'll try to investigate in the next day or so...
>
> ok, cool!

or today :)

it looks like $r->dir_config->set(FOO => 'bar');

persists for the life of the request only (at least with 1.3.14 + 1.24_02)

just in case it was a burining question in everyone's mind :)

--Geoff