[prev in list] [next in list] [prev in thread] [next in thread]
List: apache-modperl
Subject: Re: [MP2] Problem when defining new directives in a container
From: "titetluc titetluc" <titetluc () gmail ! com>
Date: 2008-10-14 14:52:57
Message-ID: 9b0e769d0810140752l3e4d78cew89386d0e8d7670e9 () mail ! gmail ! com
[Download RAW message or body]
Any ideas ?
Gaetan
2008/10/7 titetluc titetluc <titetluc@gmail.com>
> Hello all,
>
> I am developing a new module which defines 2 new directives (TestDirective1
> and TestDirective2). These directives are usable in a container (Location,
> Directory, ...).
> The following code defines the directives :
>
> =====BEGIN CODE=====================================
> package TestDirective;
> use warnings;
> use strict;
> use Carp;
>
> use Apache2::Const -compile => qw(RAW_ARGS);
> use Apache2::CmdParms ();
> use Apache2::Module ();
> use Apache2::Directive ();
> use Apache2::Const qw(:common);
>
> my @directives = (
> {
> name => 'TestDirective1',
> func => __PACKAGE__ . '::TestDirective1',
> args_how => Apache2::Const::RAW_ARGS,
> },
> {
> name => 'TestDirective2',
> func => __PACKAGE__ . '::TestDirective2',
> args_how => Apache2::Const::RAW_ARGS,
> },
> );
>
> Apache2::Module::add(__PACKAGE__, \@directives);
>
> sub TestDirective1 {
> my ($self, $parms, $arg) = @_;
> print STDERR "hello\n";
> $self->{TestDirective1} = 'hello';
> return;
> }
>
> sub TestDirective2 {
> my ($self, $parms, $arg) = @_;
> my $td1 = Apache2::Module::get_config(__PACKAGE__, $parms->server);
>
> if (defined $td1){
> print STDERR "world\n";
> }
> $self->{TestDirective2} = 'world';
> return;
> }
>
>
> sub response {
> my ($self,$r) = @_;
> print 'hello world';
> return OK;
> }
>
> 1;
>
> =====END CODE======================================
>
>
> When using the new directives with the following configuration file
>
> =====BEGIN CONFIG======================================
> PerlLoadModule TestDirective;
>
> <Location /test>
> SetHandler perl-script
> TestDirective1
> TestDirective2
>
> PerlResponseHandler TestDirectives->response
> </Location>
> =====END CONFIG======================================
>
> STDERR output, when starting Apache, is
> "hello
> world"
> => correct
>
>
> But when using the new directives with the following configuration file
>
> =====BEGIN CONFIG======================================
> PerlLoadModule TestDirective;
>
> <Location /test>
> SetHandler perl-script
> TestDirective2
>
> PerlResponseHandler TestDirectives->response
> </Location>
> =====END CONFIG======================================
>
> STDERR output, when starting Apache, is
> "world"
> => incorrect
>
> STDERR is not empty (it should)
> What is wrong in the TestDirective::TestDirective2 function ?
> Which test do I have to apply ('defined $td1' is not the correct test !!!)
> ?
>
> Thanks
>
> Gaetan
>
>
[Attachment #3 (text/html)]
<div dir="ltr">Any ideas ?<br><br>Gaetan<br><br><div class="gmail_quote">2008/10/7 \
titetluc titetluc <span dir="ltr"><<a \
href="mailto:titetluc@gmail.com">titetluc@gmail.com</a>></span><br><blockquote \
class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt \
0pt 0.8ex; padding-left: 1ex;"> <div dir="ltr">Hello all,<br><br>I am developing a \
new module which defines 2 new directives (TestDirective1 and TestDirective2). These \
directives are usable in a container (Location, Directory, ...).<br>The following \
code defines the directives :<br>
<br>=====BEGIN CODE=====================================<br>package \
TestDirective;<br>use warnings;<br>use strict;<br>use Carp;<br><br>use Apache2::Const \
-compile => qw(RAW_ARGS);<br>use Apache2::CmdParms ();<br>use Apache2::Module \
();<br>
use Apache2::Directive ();<br>use Apache2::Const qw(:common);<br><br>my @directives = \
(<br> {<br> \
\
name => \
'TestDirective1',<br> \
func \
=> __PACKAGE__ . '::TestDirective1',<br>
\
args_how => \
Apache2::Const::RAW_ARGS,<br> \
},<br> {<br> \
\
name => \
'TestDirective2',<br> \
func \
=> __PACKAGE__ . '::TestDirective2',<br>
\
args_how => \
Apache2::Const::RAW_ARGS,<br> \
},<br> \
);<br><br>Apache2::Module::add(__PACKAGE__, \@directives);<br><br>sub TestDirective1 \
{<br> my ($self, $parms, $arg) = @_;<br> print \
STDERR "hello\n";<br>
$self->{TestDirective1} = \
'hello';<br> return;<br>}<br><br>sub TestDirective2 \
{<br> my ($self, $parms, $arg) = @_;<br> my $td1 \
= Apache2::Module::get_config(__PACKAGE__, $parms->server);<br><br>
if (defined $td1){<br> \
print STDERR "world\n";<br> }<br> \
$self->{TestDirective2} = 'world';<br> \
return;<br>}<br><br><br>sub response {<br> my ($self,$r) = \
@_;<br> print 'hello world';<br>
return OK;<br>}<br><br>1;<br><br>=====END \
CODE======================================<br> <br><br>When using the new directives \
with the following configuration file<br><br>=====BEGIN \
CONFIG======================================<br>
PerlLoadModule TestDirective;<br><br><Location /test><br> \
SetHandler perl-script<br> TestDirective1<br> \
TestDirective2<br><br> PerlResponseHandler \
TestDirectives->response<br></Location><br>=====END \
CONFIG======================================<br>
<br> STDERR output, when starting Apache, is \
<br>"hello<br>world"<br>=> correct<br><br><br>But when using the \
new directives with the following configuration file<br> <br>
=====BEGIN CONFIG======================================<br>
PerlLoadModule TestDirective;<br>
<br>
<Location /test><br>
SetHandler perl-script<br>
TestDirective2<br>
<br>
PerlResponseHandler TestDirectives->response<br>
</Location><br>
=====END CONFIG======================================<br>
<br>
STDERR output, when starting Apache, is <br>
"world"<br>
=> incorrect<br><br>STDERR is not empty (it should)<br>What is wrong in the \
TestDirective::TestDirective2 function ?<br>Which test do I have to apply \
('defined $td1' is not the correct test !!!) ?<br><br>Thanks<br>
<br>Gaetan<br><br></div>
</blockquote></div><br></div>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic