You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by Doug MacEachern <do...@covalent.net> on 2002/08/24 18:35:21 UTC
pluggable sections
i realize there are plenty of outstanding issues that require
attention, but i got this itch and had to scratch it..
as you'll see in the cvs commits, there is now support for pluggable
<Perl> sections. the idea is that we will have a default handler,
which one can override. i'll leave the implementation of the default
handler to anybody who is interested/able. thinking the initial
prototype should be pure Perl. can then be re-written in xs or have
an alternate xs implementation to the pure Perl one. would be nice to
make it subclass-able, like a ModPerl::Registry for <Perl> sections.
one pita is that 2.0 parses the body of *every* <Container>, so the
code within <Perl> must be re-strung together before it is eval-ed.
the Apache::Directive->as_string method was added as a helper for
this, there's a chance that certain code can trip up the apache
parser. but we can worry about that if/when it happens.
i had thought one could build an ap_directive_t* tree, rather than
generate strings of config that get parsed. might still be possible,
but it looks like the latter will be more straight-forward and less
error-prone.
the other issue is that modperl_hook_init must be called earlier than
normal to handle <Perl> sections. this means certain directives must
come before <Perl>, such as PerlSwitches. i'll be putting some checks
in for stuff like that.
hopefully the test <Perl> handler in modperl_extra.pl will be a good
enough example to go on. also notice there, the feature request of
being able to specify which package <Perl> code is compiled into can
be implemented by the handler like so:
<Perl handler=MyConfig,package=MyPackage>
...
</Perl>
sub MyConfig::handler {
my($parms, $args) = @_;
my $code = $parms->directive->as_string;
my $package = $args->{package} || 'Apache::ReadConfig';
eval "package $package; $code";
...
one could also do something like this:
<Perl handler=MyConfig>
...
</Perl>
sub MyConfig::handler : method {
my($self, $parms, $args) = @_;
my $package = ref($self) || $self;
...
}
have fun.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org