perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philippe M. Chiasson" <go...@cpan.org>
Subject Re: allowing <Perl > sections on a per-dir level
Date Sat, 24 May 2003 10:14:39 GMT
On Fri, 2003-05-23 at 22:39, Geoffrey Young wrote:
> I tried to use <Perl > sections today within an .htaccess file - something I
> used to do often with 1.3 - only to find that they weren't allowed on a
> per-directory basis.
> 
> in taking a look at the various directives, there are a few that are only
> allowed on a per-server basis that don't seem to make sense <Perl >, PerlPassEnv,
and 
> PerlModule.  while the first two make sense, I'm not sure about PerlModule, though it

> seems to make sense that you allow PerlModule in an .htaccess file for people that don't

> have access to the main config - I'm pretty sure you can put PerlModule in .htaccess
files 
> in mp1, but I'm not sure.
> 
> is there a reason that we can't allow these on a per-dir
> level that I'm not seeing?

Well, one things that springs to mind for <Perl > sections.

If you configure a <Perl > section per-directory or per-location, does
it mean that you will execute the code it contains on each request that
matches that location/directory ? Especially with the new extended
handlers for <Perl > blocks... Or once you change the content of the
.htaccess , how do you insure that things are reconfigured proprely?

I'd say it definitely doesn't make sense to have <Perl > blocks in
<Location> or <Directory> blocks. I can see why it could be usefull to
put <Perl > blocks in .htaccess files, but I can't tell on top of my
head how they behave in mp1.. Is the code executed only once ? or for
each request?

> anyway, below is a patch for all but PerlModule. all tests pass, though I couldn't write
a 
> test for <Perl > - the one I had though about  triggered perl early and PerlSwitches
threw 
> an error.
> 
> --Geoff
> 
> 
> Index: src/modules/perl/mod_perl.c
> ===================================================================
> RCS file: /home/cvspublic/modperl-2.0/src/modules/perl/mod_perl.c,v
> retrieving revision 1.172
> diff -u -r1.172 mod_perl.c
> --- src/modules/perl/mod_perl.c 20 May 2003 06:53:47 -0000      1.172
> +++ src/modules/perl/mod_perl.c 23 May 2003 14:29:03 -0000
> @@ -689,9 +689,9 @@
>       MP_CMD_DIR_TAKE2("PerlSetVar", set_var, "PerlSetVar"),
>       MP_CMD_DIR_ITERATE2("PerlAddVar", add_var, "PerlAddVar"),
>       MP_CMD_DIR_TAKE2("PerlSetEnv", set_env, "PerlSetEnv"),
> -    MP_CMD_SRV_TAKE1("PerlPassEnv", pass_env, "PerlPassEnv"),
> -    MP_CMD_SRV_RAW_ARGS_ON_READ("<Perl", perl, "Perl Code"),
> -    MP_CMD_SRV_RAW_ARGS("Perl", perldo, "Perl Code"),
> +    MP_CMD_DIR_TAKE1("PerlPassEnv", pass_env, "PerlPassEnv"),
> +    MP_CMD_DIR_RAW_ARGS_ON_READ("<Perl", perl, "Perl Code"),
> +    MP_CMD_DIR_RAW_ARGS("Perl", perldo, "Perl Code"),
> 
>       MP_CMD_DIR_TAKE1("PerlSetInputFilter", set_input_filter,
>                        "filter[;filter]"),
> Index: src/modules/perl/modperl_cmd.h
> ===================================================================
> RCS file: /home/cvspublic/modperl-2.0/src/modules/perl/modperl_cmd.h,v
> retrieving revision 1.21
> diff -u -r1.21 modperl_cmd.h
> --- src/modules/perl/modperl_cmd.h      3 Apr 2003 06:23:53 -0000       1.21
> +++ src/modules/perl/modperl_cmd.h      23 May 2003 14:29:03 -0000
> @@ -125,4 +125,8 @@
>       AP_INIT_RAW_ARGS( name, modperl_cmd_##item, NULL, \
>         OR_ALL|EXEC_ON_READ, desc )
> 
> +#define MP_CMD_DIR_RAW_ARGS(name, item, desc) \
> +    AP_INIT_RAW_ARGS( name, modperl_cmd_##item, NULL, \
> +      OR_ALL, desc )
> +
>   #endif /* MODPERL_CMD_H */
> Index: t/response/TestDirective/env.pm
> ===================================================================
> RCS file: /home/cvspublic/modperl-2.0/t/response/TestDirective/env.pm,v
> retrieving revision 1.2
> diff -u -r1.2 env.pm
> --- t/response/TestDirective/env.pm     11 Apr 2002 11:08:44 -0000      1.2
> +++ t/response/TestDirective/env.pm     23 May 2003 14:29:03 -0000
> @@ -14,7 +14,7 @@
>   sub handler {
>       my $r = shift;
> 
> -    plan $r, tests => 4;
> +    plan $r, tests => 5;
> 
>       ok t_cmp('env_dir1', env_get('srv1'),
>                'per-dir override per-srv');
> @@ -28,7 +28,11 @@
>       #setup by Apache::TestRun
>       ok t_cmp('test.host.name',
>                $ENV{APACHE_TEST_HOSTNAME},
> -             'PassEnv');
> +             'PassEnv - server level');
> +
> +    ok t_cmp('z80',
> +             $ENV{APACHE_TEST_HOSTTYPE},
> +             'PassEnv - directory level');
> 
>       Apache::OK;
>   }
> @@ -56,3 +60,4 @@
>   PerlSetEnv TestDirective__env_dir2 ToBeLost
>   PerlSetEnv TestDirective__env_dir2 env_dir2
> 
> +PerlPassEnv APACHE_TEST_HOSTTYPE
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
> For additional commands, e-mail: dev-help@perl.apache.org
-- 
-- -----------------------------------------------------------------------------
Philippe M. Chiasson /gozer\@(cpan|ectoplasm)\.org/ 88C3A5A5 (122FF51B/C634E37B)
http://gozer.ectoplasm.org/    F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3 A5A5
Q: It is impossible to make anything foolproof because fools are so ingenious.
perl -e'$$=\${gozer};{$_=unpack(P7,pack(L,$$));/^JAm_pH\n$/&&print||$$++&&redo}'

Mime
View raw message