Revision: 32
Author: phred_moyer
Date: 2006-05-21 23:20:02 -0700 (Sun, 21 May 2006)
ViewCVS: http://svn.sourceforge.net/apache-dispatch/?rev=32&view=rev
Log Message:
-----------
- Some cleanup of test libraries
- Map the directive names in Apache::Dispatch::Util to Apache::Dispatch space
to work around the issue of command_directive methods not being accessible
for inheritance. See the Apache::Dispatch source for the symbol table
manipulations.
Modified Paths:
--------------
trunk/lib/Apache/Dispatch.pm
trunk/t/lib/Apache/Foo.pm
trunk/t/lib/Apache2/Foo/Bar.pm
Modified: trunk/lib/Apache/Dispatch.pm
===================================================================
--- trunk/lib/Apache/Dispatch.pm 2006-05-22 01:28:57 UTC (rev 31)
+++ trunk/lib/Apache/Dispatch.pm 2006-05-22 06:20:02 UTC (rev 32)
@@ -15,16 +15,38 @@
use mod_perl 1.2401;
use Apache::Constants qw(OK DECLINED SERVER_ERROR);
-use Apache::Log ();
-use Apache::Dispatch::Util;
-push @Apache::Dispatch::ISA, qw(Apache::Dispatch::Util);
+use Apache::Log ();
+use Apache::Dispatch::Util ();
+BEGIN {
+ push @Apache::Dispatch::ISA, qw(Apache::Dispatch::Util);
+
+ {
+
+ #---------------------------------------------------------------------
+ # there is a problem with using command_table methods with inheritance
+ # so here we map the command table directive names to the methods in
+ # Apache::Dispatch::Util using the symbol table. this allows us to
+ # share the code between Apache::Dispatch and Apache2::Dispatch
+ #---------------------------------------------------------------------
+
+ my @dir_names =
+ map { $_->{name} } @{Apache::Dispatch::Util->directives};
+ no strict 'refs';
+ foreach my $directive (@dir_names) {
+ *{"Apache::Dispatch::$directive"} =
+ \&{"Apache::Dispatch::Util::$directive"};
+ }
+
+ }
+}
+
$Apache::Dispatch::PUREPERL = 0; # set during perl Makefile.PL
if ($Apache::Dispatch::PUREPERL == 0) {
- require Apache::ModuleConfig;
+ require Apache::ModuleConfig;
require DynaLoader;
- push @Apache::Dispatch::ISA, qw(DynaLoader);
+ push @Apache::Dispatch::ISA, qw(DynaLoader);
__PACKAGE__->bootstrap($VERSION);
}
@@ -204,7 +226,8 @@
# if not, decline the request
#---------------------------------------------------------------------
- my $handler = __PACKAGE__->_check_dispatch($object, $method, $autoload, $log, $debug);
+ my $handler =
+ __PACKAGE__->_check_dispatch($object, $method, $autoload, $log, $debug);
if ($handler) {
$log->info("\t$uri was translated into $class->$method")
@@ -223,17 +246,18 @@
foreach my $extra (@extras) {
if ($extra eq "PRE") {
$prehandler =
- __PACKAGE__->_check_dispatch($object, "pre_dispatch", $autoload, $log, $debug);
+ __PACKAGE__->_check_dispatch($object, "pre_dispatch", $autoload,
+ $log, $debug);
}
elsif ($extra eq "POST") {
$posthandler =
- __PACKAGE__->_check_dispatch($object, "post_dispatch", $autoload, $log,
- $debug);
+ __PACKAGE__->_check_dispatch($object, "post_dispatch", $autoload,
+ $log, $debug);
}
elsif ($extra eq "ERROR") {
$errorhandler =
- __PACKAGE__->_check_dispatch($object, "error_dispatch", $autoload, $log,
- $debug);
+ __PACKAGE__->_check_dispatch($object, "error_dispatch", $autoload,
+ $log, $debug);
}
}
Modified: trunk/t/lib/Apache/Foo.pm
===================================================================
--- trunk/t/lib/Apache/Foo.pm 2006-05-22 01:28:57 UTC (rev 31)
+++ trunk/t/lib/Apache/Foo.pm 2006-05-22 06:20:02 UTC (rev 32)
@@ -1,4 +1,4 @@
-package Apache::Foo::Foo;
+package Apache::Foo;
use Apache::Constants qw( OK SERVER_ERROR );
use strict;
@@ -6,24 +6,29 @@
sub dispatch_foo {
my $class = shift;
my $r = shift;
- $r->log->debug(__PACKAGE__ . "->dispatch_foo()\n";
+ $r->log->debug(__PACKAGE__ . "->dispatch_foo()");
$r->send_http_header('text/plain');
- $r->print("Foo::Foo->dispatch_foo()");
+ $r->print(__PACKAGE__ . "->dispatch_foo()");
return OK;
}
-sub dispatch_bar {
- print STDERR "Foo->dispatch_bar()\n";
+sub dispatch_uhoh {
+ my ($class, $r) = @_;
+
+ $r->log->debug(__PACKAGE__ . "->dispatch_bar()");
return SERVER_ERROR;
}
sub pre_dispatch {
- print STDERR "Foo->pre_dispatch()\n";
+ my ($class, $r) = @_;
+ $r->log->debug(__PACKAGE__ . "->pre_dispatch()");
}
sub post_dispatch {
- print STDERR "Foo->post_dispatch()\n";
+ my ($class, $r) = @_;
+ $r->log->debug(__PACKAGE__ . "->post_dispatch()");
+ $r->print($Apache::Foo::output);
}
sub error_dispatch {
@@ -31,7 +36,7 @@
my $r = shift;
$r->send_http_header('text/plain');
$r->print("Yikes! Foo->dispatch_error()");
- print STDERR "Yikes! Foo->dispatch_error()\n";
+ $r->log->error("Yikes! " . __PACKAGE__ . "->dispatch_error()");
return OK;
}
@@ -39,8 +44,8 @@
my $class = shift;
my $r = shift;
$r->send_http_header('text/plain');
- $r->print("Foo::Foo->dispatch_index()");
- print STDERR "Foo::Foo->dispatch_index()\n";
+ $r->print(__PACKAGE__ . "->dispatch_index()");
+ $r->log->debug(__PACKAGE__ . "->dispatch_index()");
return OK;
}
Modified: trunk/t/lib/Apache2/Foo/Bar.pm
===================================================================
--- trunk/t/lib/Apache2/Foo/Bar.pm 2006-05-22 01:28:57 UTC (rev 31)
+++ trunk/t/lib/Apache2/Foo/Bar.pm 2006-05-22 06:20:02 UTC (rev 32)
@@ -25,8 +25,8 @@
$r->log->debug(__PACKAGE__ . "->dispatch_baz()");
$r->content_type('text/plain');
- $Foo::Foo::output = "pid $$";
- $r->print(__PACKAGE__ . "->dispatch_index()");
+ $Apache2::Foo::Foo::output = "pid $$";
+ $r->print(__PACKAGE__ . "->dispatch_baz()");
return Apache2::Const::OK;
}
@@ -35,7 +35,7 @@
my $r = shift;
# delay printing headers until all processing is done
$r->content_type('text/plain');
- $r->print($Foo::Foo::output);
+ $r->print($Apache2::Foo::Foo::output);
$r->log->debug(__PACKAGE__ . "->post_dispatch()");
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|