You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Matt Sergeant <ma...@sergeant.org> on 2000/06/30 12:41:27 UTC

Config directives question

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?

-- 
<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


Re: Config directives question

Posted by Matt Sergeant <ma...@sergeant.org>.
On Fri, 30 Jun 2000, Doug MacEachern wrote:

> 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 :)

<g> - glad I signed up for that session now - look forward to meeting you
there.

Shame it can't be done right now though, and I can't really justify adding
that sort of functionality to AxKit at the moment. I guess I'll have to
setup a custom parser to call my own callbacks.

-- 
<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


Re: Config directives question

Posted by Doug MacEachern <do...@covalent.net>.
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)