[prev in list] [next in list] [prev in thread] [next in thread]
List: apache-modperl
Subject: Problem with EXEC_ON_READ, custom block content
From: John Hallam <john () mmmi ! sdu ! dk>
Date: 2008-03-24 14:44:43
Message-ID: Pine.LNX.4.64.0803241536200.9371 () hune ! mip ! sdu ! dk
[Download RAW message or body]
I'm trying to create a custom block directive, following the
documentation in the ModPerl2 book (or the on-line documentation). The
minimal code for the problem I am seeing is below. I have the following
block in apache2.conf for the new block <StdVHost ...> and the module is
in the /root/apache2 tree as required.
---
PerlSwitches -wT -Mlib=/root/apache2
PerlLoadModule MyApache::StdVHost;
<StdVHost test arguments>
<Directory /var/www >
Order deny,allow
Deny from all
</Directory>
</StdVHost>
---
I see two behaviours: if EXEC_ON_READ is set, by removing the
string ', #' in the code below, the handler is never invoked -- at least
die "..." is not visibly executed; if EXEC_ON_READ is unset, the handler
is invoked but $cont is just the first line <Directory /var/www> and not
the whole block. Neither is what I wanted :-((.
The problem seems to have been reported back in 2005, with similar
code, and an implication that it was to be fixed. So what am I doing
wrong?
Thanks in advance,
John Hallam
---
# PERL module for automating a standard virtual host configuration for Apache
package MyApache::StdVHost;
use strict;
use warnings FATAL => 'all';
use Apache2::Const -compile => qw(RSRC_CONF RAW_ARGS EXEC_ON_READ);
use Apache2::CmdParms ();
use Apache2::Module ();
use Apache2::Directive ();
use Apache2::ServerUtil ();
my @directives
= (
# Definition of a StdVHost container
#
# Note that EXEC_ON_READ is necessary, according to the
# mod_perl2 book, but in fact breaks things if included
# by stopping the handler from being called.
{
name => '<StdVHost',
func => __PACKAGE__ . '::StdVHost',
errmsg => 'StdVHost minimal test package',
args_how => Apache2::Const::RAW_ARGS,
req_override => Apache2::Const::RSRC_CONF, #| Apache2::Const::EXEC_ON_READ,
},
);
Apache2::Module::add( __PACKAGE__, \@directives );
# Handler for the config directive.
#
# It is unclear how to get the content of the <StdVHost> directive
# container: maybe it has not been read when this routine is called?
# With RAW_ARGS, the first line of the content is available as
# $parms->directive->as_string but how do you get the rest??
sub StdVHost {
my ($self,$parms,$arg) = @_;
my $cont = $parms->directive->as_string();
die "StdVHost arg='$arg' cont='$cont'";
}
1;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic