perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Geoffrey Young <ge...@modperlcookbook.org>
Subject allowing <Perl > sections on a per-dir level
Date Fri, 23 May 2003 14:39:37 GMT
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?

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


Mime
View raw message