Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: ModPerl: ModPerl
[MP2] Problem when defining new directives in a container
 

Index | Next | Previous | View Flat


titetluc at gmail

Oct 7, 2008, 1:49 AM


Views: 390
Permalink
[MP2] Problem when defining new directives in a container

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

Subject User Time
[MP2] Problem when defining new directives in a container titetluc at gmail Oct 7, 2008, 1:49 AM
    Re: [MP2] Problem when defining new directives in a container titetluc at gmail Oct 14, 2008, 7:52 AM

  Index | Next | Previous | View Flat
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.