[MP2] Problem when defining new directives in a container

[MP2] Problem when defining new directives in a container

am 07.10.2008 10:49:24 von titetluc

------=_Part_34635_28690877.1223369365023
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

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;


SetHandler perl-script
TestDirective1
TestDirective2

PerlResponseHandler TestDirectives->response

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


SetHandler perl-script
TestDirective2

PerlResponseHandler TestDirectives->response

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

------=_Part_34635_28690877.1223369365023
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

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



------=_Part_34635_28690877.1223369365023--

Re: [MP2] Problem when defining new directives in a container

am 14.10.2008 16:52:57 von titetluc

------=_Part_99382_15231727.1223995977317
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Any ideas ?

Gaetan

2008/10/7 titetluc titetluc

> 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;
>
>
> SetHandler perl-script
> TestDirective1
> TestDirective2
>
> PerlResponseHandler TestDirectives->response
>

> =====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;
>
>
> SetHandler perl-script
> TestDirective2
>
> PerlResponseHandler TestDirectives->response
>

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

------=_Part_99382_15231727.1223995977317
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Any ideas ?

Gaetan

2008/10/7 titetluc titetluc <>

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





------=_Part_99382_15231727.1223995977317--