You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Doug MacEachern <do...@pobox.com> on 2000/02/17 01:01:25 UTC

Re: Problems with custom config directives in user written modules

On Sun, 30 Jan 2000, Dave Hayes wrote:

> I cannot seem to get custom configuration directives to work in 
> apache (1.3.11) modperl (1.21). I would presume the examples in the
> book do not work either. I found someone having similar problems
> in the list archives, to which Doug provided a workaround which also
> does not work.
> 
> Any advice about this issue is helpful. Please reply to me directly as
> well. 

works fine here, the Makefile.PL
package Apache::TestDirective;

use ExtUtils::MakeMaker;

use Apache::ExtUtils qw(command_table);
use Apache::src ();

my @directives = (
		  {   name        =>  'Directive4',
		      errmsg      =>  'Anything',
		      args_how    =>  'RAW_ARGS',
		      req_override=>  'OR_ALL',
		  },
		 );

command_table(\@directives);

WriteMakefile(
    'NAME'	=> 'Apache::TestDirective',
    'VERSION_FROM' => 'TestDirective.pm',
    'INC'	=> Apache::src->new->inc,
);

TestDirective.pm:

package Apache::TestDirective;

use strict;
use strict;
use Apache::ModuleConfig ();
use DynaLoader ();
 
if($ENV{MOD_PERL}) {
    no strict;
    $VERSION = '0.01';
    @ISA = qw(DynaLoader);
     __PACKAGE__->bootstrap($VERSION); #command table, etc.
}

sub Directive4 {
    warn "Directive4 @_\n";
}

1;
__END__

in the mod_perl source tree, I add this to t/docs/startup.pl:
use blib qw(/home/dougm/test/Apache/TestDirective);

and at the bottom of t/conf/httpd.conf:

PerlModule Apache::TestDirective
Directive4 hi

% make start_httpd
Directive4 Apache::TestDirective=HASH(0x83379d0) Apache::CmdParms=SCALAR(0x862b80c) hi

% grep Directive4 t/logs/error_log 
Directive4 Apache::TestDirective=HASH(0x83119dc)
Apache::CmdParms=SCALAR(0x8326878) hi

% make kill_httpd

try building mod_perl with PERL_TRACE=1, the 'setenv MOD_PERL_TRACE all',
you should get some useful diagnostics