On Fri, 30 Jun 2000, Matt Sergeant wrote:
> Is there any way I can write RAW_ARGS config directives like:
>
> <AxMedia screen>
> ...
> </AxMedia>
>
> And have the bit between the tags passed through to apache for processing?
> The eagle book only seems to detail processing all the directives between
> the tags myself. But I want to be more modular than that. Am I missing
> some documentation somewhere?
nope, that functionality was missing, i was wanting this too for the
Apache::DBIPool module that'll be part of my tutorial mod_perl-2.0
section at oracon:
<DBIPool dbi:mysql:db_name>
DBIPoolStart 10
DBIPoolMax 20
DBIPoolMaxSpare 10
DBIPoolMinSpare 5
DBIUserName dougm
DBIPassWord XxXx
</DBIPool>
more on that later :) anyhow, with the patch below, here's a modified
TrafficCop.pm (from the eagle book):
sub TrafficCopSpeedLimits ($$$;*) {
my($cfg, $parms, $district, $cfg_fh) = @_;
$district =~ s/>$//;
my $config = $parms->create_per_dir_config;
my $errmsg = $parms->command_loop($config);
die $errmsg if $errmsg;
$cfg->{district}->{$district} = $config;
}
sub TrafficCopSpeedLimits_END () {}
handles this in httpd.conf:
<TrafficCopSpeedLimits charlestown>
TrafficCopTicket StreetSweeping Tuesday Friday
</TrafficCopSpeedLimits>
and the configuration test dumper:
sub test {
my $r = shift;
$r->send_http_header('text/plain');
require Data::Dumper;
my $cfg = Apache::ModuleConfig->get($r);
print "$Class configuration:\n";
print Data::Dumper::Dumper($cfg) if $cfg;
while (my($key, $val) = each %{ $cfg->{district} }) {
my $tcfg = Apache::ModuleConfig->get($val);
print "$key configuration:\n";
print Data::Dumper::Dumper($tcfg) if $tcfg;
}
}
prints:
Apache::TrafficCop configuration:
$VAR1 = bless( {
'district' => {
'charlestown' => 136503732
}
}, 'Apache::TrafficCop' );
charlestown configuration:
$VAR1 = bless( {
'Ticket' => {
'StreetSweeping' => [
'Tuesday',
'Friday'
]
}
}, 'Apache::TrafficCop' );
Index: src/modules/perl/ModuleConfig.xs
===================================================================
RCS file: /home/cvs/modperl/src/modules/perl/ModuleConfig.xs,v
retrieving revision 1.10
diff -u -r1.10 ModuleConfig.xs
--- src/modules/perl/ModuleConfig.xs 2000/04/03 04:48:52 1.10
+++ src/modules/perl/ModuleConfig.xs 2000/06/30 19:31:44
@@ -75,6 +75,9 @@
*type = MP_TYPE_SRV;
return s->module_config;
}
+ else if(SvIOK(sv)) {
+ return (void *)SvIV(sv);
+ }
else {
croak("Argument is not an Apache or Apache::Server object");
}
@@ -192,6 +195,27 @@
OUTPUT:
buff
RETVAL
+
+void *
+create_per_dir_config(parms)
+ Apache::CmdParms parms
+
+ CODE:
+ RETVAL = ap_create_per_dir_config(parms->pool);
+
+ OUTPUT:
+ RETVAL
+
+const char *
+command_loop(parms, config)
+ Apache::CmdParms parms
+ void *config
+
+ CODE:
+ RETVAL = ap_srm_command_loop(parms, config);
+
+ OUTPUT:
+ RETVAL
char *
path(parms)