apache-dispatch-devel Mailing List for Apache::Dispatch (Page 4)
Brought to you by:
geoffrey_young,
phred_moyer
You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
(4) |
Apr
(33) |
May
(10) |
Jun
(22) |
Jul
(3) |
Aug
(15) |
Sep
(3) |
Oct
(3) |
Nov
|
Dec
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
(5) |
Sep
|
Oct
|
Nov
|
Dec
(9) |
| 2008 |
Jan
(6) |
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
(11) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
| 2009 |
Jan
|
Feb
|
Mar
|
Apr
(12) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2010 |
Jan
|
Feb
(3) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <phr...@us...> - 2006-07-22 07:04:23
|
Revision: 48 Author: phred_moyer Date: 2006-07-22 00:04:21 -0700 (Sat, 22 Jul 2006) ViewCVS: http://svn.sourceforge.net/apache-dispatch/?rev=48&view=rev Log Message: ----------- - Implemented the MY:: overrides so that the build behaves well when Apache::Test is not present. Example drawn from WebService::CaptchasDotNet, however Apache::TestMM::generate_script was used instead of Apache::TestRun->generate_script to get it working in this implementation. Modified Paths: -------------- trunk/Makefile.PL Modified: trunk/Makefile.PL =================================================================== --- trunk/Makefile.PL 2006-06-22 06:42:07 UTC (rev 47) +++ trunk/Makefile.PL 2006-07-22 07:04:21 UTC (rev 48) @@ -3,8 +3,63 @@ require 5.005; use strict; -use warnings FATAL => 'all'; +use constant HAS_APACHE_TEST => eval { + require Apache::Test; + require Apache::TestMM; + + Apache::TestMM->import(qw(test clean)); + Apache::TestMM::filter_args(); + + my %args = @Apache::TestMM::Argv; + + die 'suitable httpd required' + unless ( $args{apxs} + or $args{httpd} + or $ENV{APACHE_TEST_HTTPD} + or $ENV{APACHE_TEST_APXS}); + + Apache::TestMM::generate_script('t/TEST'); + + return Apache::TestMM->test; +}; + +warn $@ if $@; + +sub MY::test { + + my $test = shift->MM::test(@_); + + eval { require Test::More } or return <<EOF; +test:: +\t\@echo sorry, cannot run tests without Test::More +EOF + + return HAS_APACHE_TEST if HAS_APACHE_TEST; + + if (eval { require Devel::Cover }) { + $test .= <<EOF; +testcover :: + cover -delete + HARNESS_PERL_SWITCHES=-MDevel::Cover make test + cover +EOF + } + + return $test; +} + +sub MY::clean { + + if (HAS_APACHE_TEST) { + require Apache::TestMM; + + return Apache::TestMM::clean(@_); + } + + return shift->MM::clean(@_); +} + ## which mp version ( 1.2x or 2.0.x) my ($mp_wanted, $mp_ver) = &get_mp_ver(); @@ -12,25 +67,11 @@ my %prereq = ('Apache::Test' => "1.23"); -my %makefile_params = ( - 'VERSION' => '0.10', - ); +my %makefile_params = ('VERSION' => '0.10',); -# enable "make test" -require Apache::TestMM; -Apache::TestMM->import(qw(test clean)); - -# accept configs from command line. -Apache::TestMM::filter_args(); - -my @scripts = qw(t/TEST); -Apache::TestMM::generate_script(@scripts); - -$makefile_params{clean} = {FILES => "@scripts"}; - if ($mp_wanted == 2) { # mod_perl2 specific makefile $prereq{'mod_perl2'} = 1.99023; # this covers the naming change - $makefile_params{'NAME'} = 'Apache2::Dispatch'; + $makefile_params{'NAME'} = 'Apache2::Dispatch'; $makefile_params{'PREREQ_PM'} = \%prereq; require ModPerl::MM; @@ -48,34 +89,34 @@ if ($@ || $ENV{DISPATCH_PUREPERL}) { print -"\nBuilding without Custom Apache Directives, use 'PerlSetVar' for configuration.\n\n"; +"Building without Custom Apache Directives, use 'PerlSetVar' for configuration.\n\n"; $makefile_params{'PL_FILES'} = {'set_pureperl.PL' => '1'}; $makefile_params{'C'} = []; } else { - print "\nBuilding with Custom Apache Directives ('DispatchPrefix'). You + print "Building with Custom Apache Directives ('DispatchPrefix'). You will need a C compiler and Apache/mod_perl sources.\n\n"; - $makefile_params{'PL_FILES'} = {'set_pureperl.PL' => '0'}; - $makefile_params{'clean'} = {FILES => '*.xs*'}; + $makefile_params{'PL_FILES'} = {'set_pureperl.PL' => '0'}; + $makefile_params{'clean'} = {FILES => '*.xs*'}; import Apache::ExtUtils qw(command_table); require Apache::Dispatch::Util; - my @directives = Apache::Dispatch::Util->directives(); + my @directives = Apache::Dispatch::Util->directives(); command_table(\@directives); - - my $inc = Apache::src->new->inc; + + my $inc = Apache::src->new->inc; die "Can't find mod_perl header files installed" unless $inc; $makefile_params{'INC'} = $inc; - } - $makefile_params{'PREREQ_PM'} = {mod_perl => 1.2401}; + } + $makefile_params{'PREREQ_PM'} = {mod_perl => 1.2401}; require ExtUtils::MakeMaker; ExtUtils::MakeMaker::WriteMakefile( - NAME => __PACKAGE__, + NAME => __PACKAGE__, PREREQ_PM => \%prereq, - %makefile_params, + %makefile_params, ); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: Fred M. <fr...@ta...> - 2006-06-28 16:56:53
|
>> I dropped an updated release candidate at that url that has a the oo >> bugfix and test. Let me know if you get a chance to test it, will >> probably hack on it more this weekend if you want to wait til next >> week. > > ah, I knew there was something else I was supposed to test :) > > ok, I just tried it out as > > $ perl Makefile.PL && make && make test > > and it balked. no problem, the Makefile.PL just needs some tweaking. > > and, as it turns out, I spent the morning doing the same for > Apache-SizeLimit. so, I'd suggest looking at the following files > > Makefile.PL > t/apache/all.t > > here > > http://svn.apache.org/viewvc/perl/Apache-SizeLimit/trunk/ > > not to add extra work, but if you have the tuits. really, it's all a > matter of how nice you want to be to your users. No problem, I will check those out. I looked at the captcha stuff initially but didn't grok it right away, but dug around a week ago and I can dig it now. I will refactor the Makefile.PL this weekend. |
|
From: Geoffrey Y. <ge...@mo...> - 2006-06-28 16:39:44
|
Fred Moyer wrote: >>>http://www.redhotpenguin.com/Apache-Dispatch-0.10.tar.gz >>> >>>It builds for me and all tests pass on mp1 and mp2, hopefully it will >>>for you also :) >>> >>> >>>>it might take me a few days to test it, unfortunately, but I'll do it >>>>"soonish" I promise :) > > > I dropped an updated release candidate at that url that has a the oo > bugfix and test. Let me know if you get a chance to test it, will > probably hack on it more this weekend if you want to wait til next week. ah, I knew there was something else I was supposed to test :) ok, I just tried it out as $ perl Makefile.PL && make && make test and it balked. no problem, the Makefile.PL just needs some tweaking. and, as it turns out, I spent the morning doing the same for Apache-SizeLimit. so, I'd suggest looking at the following files Makefile.PL t/apache/all.t here http://svn.apache.org/viewvc/perl/Apache-SizeLimit/trunk/ and see if they don't make a degree of sense and are something you can migrate to Apache-Dispatch. really, the problem is that for mp1 modules you can't rely on someone having Apache-Test installed, and even if they do you can't rely on $ perl Makefile.PL -apxs /foo/apxs so, unless you want a ton of bugreports, or you want CPAN.pm to fail, you need to take some extra steps. see also WebService-CaptchasDotNot (another one of my modules) that similarly tweaks stuff. not to add extra work, but if you have the tuits. really, it's all a matter of how nice you want to be to your users. --Geoff |
|
From: Fred M. <fr...@ta...> - 2006-06-28 15:32:08
|
>>http://www.redhotpenguin.com/Apache-Dispatch-0.10.tar.gz >> >>It builds for me and all tests pass on mp1 and mp2, hopefully it will >>for you also :) >> >>>it might take me a few days to test it, unfortunately, but I'll do it >>>"soonish" I promise :) I dropped an updated release candidate at that url that has a the oo bugfix and test. Let me know if you get a chance to test it, will probably hack on it more this weekend if you want to wait til next week. |
|
From: <phr...@us...> - 2006-06-22 06:42:11
|
Revision: 47 Author: phred_moyer Date: 2006-06-21 23:42:07 -0700 (Wed, 21 Jun 2006) ViewCVS: http://svn.sourceforge.net/apache-dispatch/?rev=47&view=rev Log Message: ----------- Update the manifest for another dist. Modified Paths: -------------- trunk/MANIFEST Modified: trunk/MANIFEST =================================================================== --- trunk/MANIFEST 2006-06-22 06:41:19 UTC (rev 46) +++ trunk/MANIFEST 2006-06-22 06:42:07 UTC (rev 47) @@ -19,5 +19,6 @@ t/01plain.t t/02extras.t t/03filter.t +t/04oo.t t/conf/extra.last.conf.in t/TEST.PL This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <phr...@us...> - 2006-06-22 06:41:24
|
Revision: 46 Author: phred_moyer Date: 2006-06-21 23:41:19 -0700 (Wed, 21 Jun 2006) ViewCVS: http://svn.sourceforge.net/apache-dispatch/?rev=46&view=rev Log Message: ----------- - add test coverage for DispatchISA, which uncovered a bug - fix bug in DispatchISA which was caused by use of Apache::Dispatch::Util in Apache::Dispatch and Apache2::Dispatch's ISAs. Modified Paths: -------------- trunk/lib/Apache/Dispatch/Util.pm trunk/lib/Apache/Dispatch.pm trunk/lib/Apache2/Dispatch.pm trunk/t/conf/extra.last.conf.in trunk/t/lib/Apache2/Foo/Bar.pm Added Paths: ----------- trunk/t/04oo.t Modified: trunk/lib/Apache/Dispatch/Util.pm =================================================================== --- trunk/lib/Apache/Dispatch/Util.pm 2006-06-07 07:15:09 UTC (rev 45) +++ trunk/lib/Apache/Dispatch/Util.pm 2006-06-22 06:41:19 UTC (rev 46) @@ -261,8 +261,7 @@ # set the ISA array for the class # this method is for internal use only #--------------------------------------------------------------------- - my $pkg; - my ($class, $log, @parents) = @_; + my ($pkg, $class, $log, @parents) = @_; # turn off strict here so we can get at the class @ISA no strict 'refs'; @@ -270,11 +269,14 @@ $log->debug("\t\@ISA for $class currently contains ", (join ", ", @{"${class}::ISA"})); $log->debug("\tabout to merge ", (join ", ", @parents)); - - # only add classes to @ISA if they are not there already + + # only add classes to @ISA if they are not there already my %seen; @{"${class}::ISA"} = grep !$seen{$_}++, (@{"${class}::ISA"}, @parents); + + $log->debug("\t\@ISA for $class now contains ", + (join ", ", @{"${class}::ISA"})); return 1; } @@ -381,7 +383,6 @@ #--------------------------------------------------------------------- my $pkg = shift; - require Data::Dumper; my ($object, $method, $autoload, $log, $debug) = @_; @@ -393,7 +394,7 @@ if $debug > 1; if ($autoload) { - $coderef = $object->can($method) || $object->can("AUTOLOAD"); + $coderef = $object->can($method) || $object->can("AUTOLOAD"); } else { $coderef = $object->can($method); Modified: trunk/lib/Apache/Dispatch.pm =================================================================== --- trunk/lib/Apache/Dispatch.pm 2006-06-07 07:15:09 UTC (rev 45) +++ trunk/lib/Apache/Dispatch.pm 2006-06-22 06:41:19 UTC (rev 46) @@ -169,7 +169,7 @@ #--------------------------------------------------------------------- if (@parents) { - $rc = __PACKAGE__->_set_ISA($class, $log, $debug, @parents); + $rc = __PACKAGE__->_set_ISA($prefix, $log, @parents); unless ($rc) { $log->error("\tDispatchISA did not return successfully!"); Modified: trunk/lib/Apache2/Dispatch.pm =================================================================== --- trunk/lib/Apache2/Dispatch.pm 2006-06-07 07:15:09 UTC (rev 45) +++ trunk/lib/Apache2/Dispatch.pm 2006-06-22 06:41:19 UTC (rev 46) @@ -119,7 +119,7 @@ #--------------------------------------------------------------------- if (@parents) { - $rc = __PACKAGE__->_set_ISA($class, $log, @parents); + $rc = __PACKAGE__->_set_ISA($prefix, $log, @parents); unless ($rc) { $log->error("\tDispatchISA did not return successfully!"); Added: trunk/t/04oo.t =================================================================== --- trunk/t/04oo.t (rev 0) +++ trunk/t/04oo.t 2006-06-22 06:41:19 UTC (rev 46) @@ -0,0 +1,13 @@ +use strict; +use warnings FATAL => 'all'; + +use Apache::Test qw(-withtestmore); +use Apache::TestRequest; + +plan tests => 2, \&need_lwp; + +my $url = '/oo/baz'; + +my $res = GET $url; +ok($res->is_success); +ok($res->content =~ m/dispatch_baz/i); Modified: trunk/t/conf/extra.last.conf.in =================================================================== --- trunk/t/conf/extra.last.conf.in 2006-06-07 07:15:09 UTC (rev 45) +++ trunk/t/conf/extra.last.conf.in 2006-06-22 06:41:19 UTC (rev 46) @@ -55,14 +55,16 @@ SetHandler perl-script DispatchRequire On DispatchAUTOLOAD On - DispatchISA Foo::Parent DispatchDebug 2 <IfDefine APACHE2> DispatchPrefix Apache2::Foo + DispatchISA Apache2::Foo::Bar PerlResponseHandler Apache2::Dispatch </IfDefine> <IfDefine APACHE1> DispatchPrefix Apache::Foo + PerlModule Apache::Foo::Bar + DispatchISA Apache::Foo::Bar PerlHandler Apache::Dispatch </IfDefine> Modified: trunk/t/lib/Apache2/Foo/Bar.pm =================================================================== --- trunk/t/lib/Apache2/Foo/Bar.pm 2006-06-07 07:15:09 UTC (rev 45) +++ trunk/t/lib/Apache2/Foo/Bar.pm 2006-06-22 06:41:19 UTC (rev 46) @@ -7,8 +7,6 @@ use Apache2::RequestRec; use Apache2::RequestIO; -@Foo::Bar::ISA = qw(Apache2::Foo::Foo); - sub dispatch_baz { my ($class, $r) = @_; $r->log->debug("$class->dispatch_baz()"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: Geoffrey Y. <ge...@mo...> - 2006-06-07 14:11:35
|
> I've wrapped up the dist candidate and posted it here, I didn't see any > place on sourceforge to put temp files. > > http://www.redhotpenguin.com/Apache-Dispatch-0.10.tar.gz > > It builds for me and all tests pass on mp1 and mp2, hopefully it will > for you also :) > > >>it might take me a few days to test it, unfortunately, but I'll do it >>"soonish" I promise :) > > > thanks :) I'll try to give it a whirl before the end of the week. --Geoff |
|
From: Fred M. <fr...@ta...> - 2006-06-07 07:22:25
|
Geoffrey Young wrote: > Fred Moyer wrote: > >>I need to do a fresh checkout and some final checks and cleanup but all >>tests are passing under both versions and I think that we will be ready >>for a (developer) release in a day or two. I talked to domm and he is >>ok with still being co-maintainer. > > > ok, great. I'd feel better if he were on this list, but if you talked > with him that'll do. I emailed him tonight with the subscription link and let him know that we would be stoked if he could join the list. > I'd say 'make dist' and I'll test it on mp1 and mp2. I'd really like > thomas to do the same, since the two of you are apparently the only > users ;) once we all ok the distribution time to upload and announce, > I'd think. I've wrapped up the dist candidate and posted it here, I didn't see any place on sourceforge to put temp files. http://www.redhotpenguin.com/Apache-Dispatch-0.10.tar.gz It builds for me and all tests pass on mp1 and mp2, hopefully it will for you also :) > it might take me a few days to test it, unfortunately, but I'll do it > "soonish" I promise :) thanks :) |
|
From: <phr...@us...> - 2006-06-07 07:15:12
|
Revision: 45 Author: phred_moyer Date: 2006-06-07 00:15:09 -0700 (Wed, 07 Jun 2006) ViewCVS: http://svn.sourceforge.net/apache-dispatch/?rev=45&view=rev Log Message: ----------- - one more slipped through the dist, everything is there now. Modified Paths: -------------- trunk/MANIFEST Modified: trunk/MANIFEST =================================================================== --- trunk/MANIFEST 2006-06-07 07:06:32 UTC (rev 44) +++ trunk/MANIFEST 2006-06-07 07:15:09 UTC (rev 45) @@ -20,3 +20,4 @@ t/02extras.t t/03filter.t t/conf/extra.last.conf.in +t/TEST.PL This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <phr...@us...> - 2006-06-07 07:06:41
|
Revision: 44 Author: phred_moyer Date: 2006-06-07 00:06:32 -0700 (Wed, 07 Jun 2006) ViewCVS: http://svn.sourceforge.net/apache-dispatch/?rev=44&view=rev Log Message: ----------- - forgot we are using extra.conf.last.in because of command directives Modified Paths: -------------- trunk/MANIFEST Modified: trunk/MANIFEST =================================================================== --- trunk/MANIFEST 2006-06-07 07:05:28 UTC (rev 43) +++ trunk/MANIFEST 2006-06-07 07:06:32 UTC (rev 44) @@ -19,4 +19,4 @@ t/01plain.t t/02extras.t t/03filter.t -t/conf/extra.conf.in +t/conf/extra.last.conf.in This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <phr...@us...> - 2006-06-07 07:05:33
|
Revision: 43 Author: phred_moyer Date: 2006-06-07 00:05:28 -0700 (Wed, 07 Jun 2006) ViewCVS: http://svn.sourceforge.net/apache-dispatch/?rev=43&view=rev Log Message: ----------- - update the manifest - update the changelog date Modified Paths: -------------- trunk/Changes trunk/MANIFEST Modified: trunk/Changes =================================================================== --- trunk/Changes 2006-06-07 07:02:25 UTC (rev 42) +++ trunk/Changes 2006-06-07 07:05:28 UTC (rev 43) @@ -1,6 +1,6 @@ Revision history for Perl extension Apache::Dispatch -0.10 05.07.2001 +0.10 06.07.2006 - move common methods to Apache::Dispatch::Util and adjust @ISA for Apache*::Dispatch modules to use common methods via inheritance - fred - deprecated $Apache::Dispatch::DEBUG directive per dev notes in favor Modified: trunk/MANIFEST =================================================================== --- trunk/MANIFEST 2006-06-07 07:02:25 UTC (rev 42) +++ trunk/MANIFEST 2006-06-07 07:05:28 UTC (rev 43) @@ -1,8 +1,11 @@ Changes MANIFEST Makefile.PL +INSTALL README ToDo +test.pl +set_pureperl.PL lib/Apache/Dispatch.pm lib/Apache/Dispatch/Util.pm lib/Apache2/Dispatch.pm This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <phr...@us...> - 2006-06-07 07:02:55
|
Revision: 42 Author: phred_moyer Date: 2006-06-07 00:02:25 -0700 (Wed, 07 Jun 2006) ViewCVS: http://svn.sourceforge.net/apache-dispatch/?rev=42&view=rev Log Message: ----------- - moved to t/lib Removed Paths: ------------- trunk/eg/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <phr...@us...> - 2006-06-07 07:02:17
|
Revision: 41 Author: phred_moyer Date: 2006-06-07 00:02:14 -0700 (Wed, 07 Jun 2006) ViewCVS: http://svn.sourceforge.net/apache-dispatch/?rev=41&view=rev Log Message: ----------- - update the manifest. Modified Paths: -------------- trunk/MANIFEST Modified: trunk/MANIFEST =================================================================== --- trunk/MANIFEST 2006-06-07 06:44:42 UTC (rev 40) +++ trunk/MANIFEST 2006-06-07 07:02:14 UTC (rev 41) @@ -6,9 +6,14 @@ lib/Apache/Dispatch.pm lib/Apache/Dispatch/Util.pm lib/Apache2/Dispatch.pm +t/lib/Apache/Bar.pm +t/lib/Apache/Foo.pm t/lib/Apache/Foo/Bar.pm t/lib/Apache/Foo/Foo.pm -t/lib/Apache/Bar.pm -t/lib/Apache/Foo.pm +t/lib/Apache/Foo/Filter.pm +t/lib/Apache2/Foo.pm t/lib/Apache2/Foo/Bar.pm -t/lib/Apache2/Foo.pm +t/01plain.t +t/02extras.t +t/03filter.t +t/conf/extra.conf.in This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <phr...@us...> - 2006-06-07 06:44:53
|
Revision: 40 Author: phred_moyer Date: 2006-06-06 23:44:42 -0700 (Tue, 06 Jun 2006) ViewCVS: http://svn.sourceforge.net/apache-dispatch/?rev=40&view=rev Log Message: ----------- - use need_lwp() rather than have_lwp() so that tests are skipped if LWP is not installed. Modified Paths: -------------- trunk/Makefile.PL trunk/t/01plain.t trunk/t/02extras.t trunk/t/03filter.t Modified: trunk/Makefile.PL =================================================================== --- trunk/Makefile.PL 2006-06-06 06:54:28 UTC (rev 39) +++ trunk/Makefile.PL 2006-06-07 06:44:42 UTC (rev 40) @@ -10,8 +10,7 @@ print STDERR "Using mod_perl/$mp_ver\n\n"; -my %prereq = ('Apache::Test' => "1.23", - 'LWP::UserAgent' => 0); +my %prereq = ('Apache::Test' => "1.23"); my %makefile_params = ( 'VERSION' => '0.10', Modified: trunk/t/01plain.t =================================================================== --- trunk/t/01plain.t 2006-06-06 06:54:28 UTC (rev 39) +++ trunk/t/01plain.t 2006-06-07 06:44:42 UTC (rev 40) @@ -4,11 +4,11 @@ use Apache::Test; use Apache::TestRequest; -plan tests => 4, \&have_lwp; +plan tests => 4, \&need_lwp; # Test Apache2::Foo->dispatch_index my $uri = '/plain'; -ok(GET_OK $uri, 'test passed'); +ok GET_OK $uri; # Test Apache2::Foo->dispatch_foo $uri = '/plain/foo'; Modified: trunk/t/02extras.t =================================================================== --- trunk/t/02extras.t 2006-06-06 06:54:28 UTC (rev 39) +++ trunk/t/02extras.t 2006-06-07 06:44:42 UTC (rev 40) @@ -4,7 +4,7 @@ use Apache::Test; use Apache::TestRequest; -plan tests => 5, \&have_lwp; +plan tests => 5;#, \&need_lwp; my $uri = '/extras'; my $res = GET $uri; Modified: trunk/t/03filter.t =================================================================== --- trunk/t/03filter.t 2006-06-06 06:54:28 UTC (rev 39) +++ trunk/t/03filter.t 2006-06-07 06:44:42 UTC (rev 40) @@ -9,10 +9,10 @@ my $version = `$httpd -v`; if ($version =~ m/Apache\/2/) { - plan skip_all => "Filter test irrelevant on mod_perl2"; + plan skip_all => "Filtering not yet implemented in Apache2::Dispatch"; } else { - plan tests => 2, \&have_lwp; + plan tests => 2, \&need_lwp; } my $url = '/filtered/foo'; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: Fred M. <fr...@ta...> - 2006-06-06 20:58:33
|
On Tue, 6 Jun 2006 7:01 am, Geoffrey Young wrote:
>> -my %prereq = ('Apache::Test' => "1.23");
>> +my %prereq = ('Apache::Test' => "1.23",
>> + 'LWP::UserAgent' => 0);
>
> ok, I'll go off on a little rant here...
>
> I have this thing about making libraries required only for testing part
> of the prereqs for a module - you're essentially saying that
> Apache::Dispatch _requires_ Apache-Test and LWP, and so if someone
> ignores the PREREQ warning and runs the tests anyway and they fail
> users
> are left scratching their heads. there are other reasons I'm against
> it
> as well, but I'll spare you the ideology talk...
I agree with the ideology here, I built A::D with a fresh 5.8.8 and the
test suite did not function properly without LWP::UA, so I put that hack
in until I could come up with something better, my bad.
> anyway, if you're interested I think the proper approach is this
>
> o adjust your Makefile.PL such that it doesn't even create a 'test'
> target if Apache::Test isn't found
>
> o adjust each test such that it skips unless need_lwp()
I will check these out tonight when I get home from work and replace the
hack with one. I dug through the Apache::Test docs/source and saw
mention of a fallback method for an a::t user agent when lwp is not
present, but have not grasped the specifics yet.
> you can see an example of the first thingy here
>
> http://search.cpan.org/src/GEOFF/WebService-CaptchasDotNet-0.06/Makefile.PL
>
> just food for thought - I'm not going to veto a release or anything if
> you don't do it. but it might be a good exercise in well implemented
> testing - by understanding exactly what your tests require (lwp,
> mod_foo, etc) then you're one step closer to avoiding test failures
> that
> fail because of an improperly configured environment rather than
> Apache-Dispatch code, and that makes your support life easier :)
Any concerns you have please keep mentioning them, I don't want this
going out the door with anything you are not 100% comfortable with. I
want this module to use best testing practices, but sometimes the "just
make it work" reflex from the day job kicks in and I slip :)
> anyway, just my $0.02...
very much appreciated, thanks for the continued help.
|
|
From: Geoffrey Y. <ge...@mo...> - 2006-06-06 13:21:51
|
> -my %prereq = ('Apache::Test' => "1.23");
> +my %prereq = ('Apache::Test' => "1.23",
> + 'LWP::UserAgent' => 0);
ok, I'll go off on a little rant here...
I have this thing about making libraries required only for testing part
of the prereqs for a module - you're essentially saying that
Apache::Dispatch _requires_ Apache-Test and LWP, and so if someone
ignores the PREREQ warning and runs the tests anyway and they fail users
are left scratching their heads. there are other reasons I'm against it
as well, but I'll spare you the ideology talk...
anyway, if you're interested I think the proper approach is this
o adjust your Makefile.PL such that it doesn't even create a 'test'
target if Apache::Test isn't found
o adjust each test such that it skips unless need_lwp()
you can see an example of the first thingy here
http://search.cpan.org/src/GEOFF/WebService-CaptchasDotNet-0.06/Makefile.PL
just food for thought - I'm not going to veto a release or anything if
you don't do it. but it might be a good exercise in well implemented
testing - by understanding exactly what your tests require (lwp,
mod_foo, etc) then you're one step closer to avoiding test failures that
fail because of an improperly configured environment rather than
Apache-Dispatch code, and that makes your support life easier :)
anyway, just my $0.02...
--Geoff
|
|
From: Geoffrey Y. <ge...@mo...> - 2006-06-06 13:06:19
|
Fred Moyer wrote: > I need to do a fresh checkout and some final checks and cleanup but all > tests are passing under both versions and I think that we will be ready > for a (developer) release in a day or two. I talked to domm and he is > ok with still being co-maintainer. ok, great. I'd feel better if he were on this list, but if you talked with him that'll do. > > Also, I had a talk accepted at the Nordic Perl Workshop on writing > applications with Apache::Dispatch (yay!). cool. > > Geoff what are the next steps to take to get a release out the door? I've made phred a co-maintainer on pause, so you're good to go on cpan once we hit that point. I'd say 'make dist' and I'll test it on mp1 and mp2. I'd really like thomas to do the same, since the two of you are apparently the only users ;) once we all ok the distribution time to upload and announce, I'd think. it might take me a few days to test it, unfortunately, but I'll do it "soonish" I promise :) --Geoff |
|
From: <phr...@us...> - 2006-06-06 06:54:30
|
Revision: 39 Author: phred_moyer Date: 2006-06-05 23:54:28 -0700 (Mon, 05 Jun 2006) ViewCVS: http://svn.sourceforge.net/apache-dispatch/?rev=39&view=rev Log Message: ----------- - minor cleanup Modified Paths: -------------- trunk/t/lib/Apache2/Foo/Bar.pm Modified: trunk/t/lib/Apache2/Foo/Bar.pm =================================================================== --- trunk/t/lib/Apache2/Foo/Bar.pm 2006-06-06 06:32:15 UTC (rev 38) +++ trunk/t/lib/Apache2/Foo/Bar.pm 2006-06-06 06:54:28 UTC (rev 39) @@ -9,32 +9,20 @@ @Foo::Bar::ISA = qw(Apache2::Foo::Foo); -#sub dispatch_index { - # test calls to /Bar/index or / -# my ($class, $r) = @_; -# $r->log_debug(__PACKAGE__ . "->dispatch_index()"); - -# $r->content_type('text/plain'); -# $r->print(__PACKAGE__ . "->dispatch_index()"); -# return Apache2::Const::OK; -#} - sub dispatch_baz { my ($class, $r) = @_; - $r->log->debug(__PACKAGE__ . "->dispatch_baz()"); + $r->log->debug("$class->dispatch_baz()"); $r->content_type('text/plain'); $Apache2::Foo::Foo::output = "pid $$"; - $r->print(__PACKAGE__ . "->dispatch_baz()"); + $r->print("$class->dispatch_baz()"); return Apache2::Const::OK; } sub post_dispatch { - my ($self, $r) = @_; - # delay printing headers until all processing is done - #$r->content_type('text/plain'); + my ($class, $r) = @_; $r->print($Apache2::Foo::Foo::output); - $r->log->debug(__PACKAGE__ . "->post_dispatch()"); + $r->log->debug("$class->post_dispatch()"); } 1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: Fred M. <fr...@ta...> - 2006-06-06 06:36:27
|
I need to do a fresh checkout and some final checks and cleanup but all tests are passing under both versions and I think that we will be ready for a (developer) release in a day or two. I talked to domm and he is ok with still being co-maintainer. Also, I had a talk accepted at the Nordic Perl Workshop on writing applications with Apache::Dispatch (yay!). Geoff what are the next steps to take to get a release out the door? -------- Original Message -------- Subject: [Apache-dispatch-devel] SF.net SVN: apache-dispatch: [38] trunk/t/conf Date: Mon, 05 Jun 2006 23:32:17 -0700 From: phr...@us... To: apa...@li... Revision: 38 Author: phred_moyer Date: 2006-06-05 23:32:15 -0700 (Mon, 05 Jun 2006) ViewCVS: http://svn.sourceforge.net/apache-dispatch/?rev=38&view=rev Log Message: ----------- - all tests passing under mp1 and mp2. Modified Paths: -------------- trunk/lib/Apache/Dispatch.pm trunk/lib/Apache2/Dispatch.pm trunk/t/conf/extra.last.conf.in trunk/t/lib/Apache2/Foo/Bar.pm Modified: trunk/lib/Apache/Dispatch.pm [...] |
|
From: <phr...@us...> - 2006-06-06 06:32:19
|
Revision: 38 Author: phred_moyer Date: 2006-06-05 23:32:15 -0700 (Mon, 05 Jun 2006) ViewCVS: http://svn.sourceforge.net/apache-dispatch/?rev=38&view=rev Log Message: ----------- - all tests passing under mp1 and mp2. Modified Paths: -------------- trunk/lib/Apache/Dispatch.pm trunk/lib/Apache2/Dispatch.pm trunk/t/conf/extra.last.conf.in trunk/t/lib/Apache2/Foo/Bar.pm Modified: trunk/lib/Apache/Dispatch.pm =================================================================== --- trunk/lib/Apache/Dispatch.pm 2006-06-06 06:30:00 UTC (rev 37) +++ trunk/lib/Apache/Dispatch.pm 2006-06-06 06:32:15 UTC (rev 38) @@ -74,7 +74,7 @@ my $autoload = $dcfg->{_autoload}; my $stat = $dcfg->{_stat}; my $prefix = $dcfg->{_prefix}; - my $uppercase = $dcfg->{_uppercase}; + my $uppercase = $dcfg->{_uppercase} || 'Off'; my $new_location = $dcfg->{_newloc}; my $require = $dcfg->{_require}; my @parents = $dcfg->{_isa} ? @{$dcfg->{_isa}} : (); @@ -99,6 +99,7 @@ # that other filters in the chain recognize us... $r->dir_config->set(Filter => 'On'); + $r = $r->filter_register; $log = $r->server->log; } Modified: trunk/lib/Apache2/Dispatch.pm =================================================================== --- trunk/lib/Apache2/Dispatch.pm 2006-06-06 06:30:00 UTC (rev 37) +++ trunk/lib/Apache2/Dispatch.pm 2006-06-06 06:32:15 UTC (rev 38) @@ -37,10 +37,6 @@ $dcfg = Apache2::Module::get_config(__PACKAGE__, $r->server, $r->per_dir_config); - my $filter = $dcfg->{_filter} - || $r->dir_config('Filter') - || 0; - my $debug = $dcfg->{_debug} || 0; my $autoload = $dcfg->{_autoload}; my $stat = $dcfg->{_stat}; @@ -61,19 +57,6 @@ $log->debug("Using Apache2::Dispatch"); - if ($filter) { - $log->debug("\tregistering handler with Apache::Filter"); - - require Apache2::Filter; - - # in case we used DispatchFilter directive instead, make sure - # that other filters in the chain recognize us... - $r->dir_config->set(Filter => 'On'); - - $r = $r->filter_register; - $log = $r->server->log; - } - $log->debug("\tchecking $uri for possible dispatch...") if $debug > 1; @@ -95,8 +78,6 @@ $uppercase, "\n\t\tDispatchStat: ", $stat, - "\n\t\tDispatchFilter: ", - $filter, "\n\t\tDispatchDebug: ", $debug, "\n\t\tDispatchLocation: ", @@ -478,28 +459,6 @@ without further modification. See the Eagle book on method handlers for more details. -=head1 FILTERING - -Apache2::Dispatch provides for output filtering using Apache::Filter -1.013 and above. - - <Location /Foo> - SetHandler perl-script - PerlHandler Apache2::Dispatch Apache::Compress - - DispatchPrefix Bar - DispatchFilter On - </Location> - -Your handler need do nothing special to make its output the start of -the chain - Apache2::Dispatch registers itself with Apache::Filter and -hides the task from your handler. Thus, any dispatched handler is -automatically Apache::Filter ready without the need for additional -code. - -The only caveat is that you must use the request object that is passed -to the handler and not get it directly using Apache->request. - =head1 AUTOLOAD Support for AUTOLOAD has been made optional, but requires special Modified: trunk/t/conf/extra.last.conf.in =================================================================== --- trunk/t/conf/extra.last.conf.in 2006-06-06 06:30:00 UTC (rev 37) +++ trunk/t/conf/extra.last.conf.in 2006-06-06 06:32:15 UTC (rev 38) @@ -24,13 +24,13 @@ SetHandler perl-script DispatchFilter On DispatchRequire On - DispatchExtras Pre Post DispatchDebug 2 <IfDefine APACHE2> DispatchPrefix Apache2::Foo PerlResponseHandler Apache2::Dispatch Apache2::Foo::Filter </IfDefine> <IfDefine APACHE1> + PerlModule Apache::Filter DispatchPrefix Apache::Foo PerlHandler Apache::Dispatch Apache::Foo::Filter </IfDefine> Modified: trunk/t/lib/Apache2/Foo/Bar.pm =================================================================== --- trunk/t/lib/Apache2/Foo/Bar.pm 2006-06-06 06:30:00 UTC (rev 37) +++ trunk/t/lib/Apache2/Foo/Bar.pm 2006-06-06 06:32:15 UTC (rev 38) @@ -9,15 +9,15 @@ @Foo::Bar::ISA = qw(Apache2::Foo::Foo); -sub dispatch_index { +#sub dispatch_index { # test calls to /Bar/index or / - my ($class, $r) = @_; - $r->log_debug(__PACKAGE__ . "->dispatch_index()"); +# my ($class, $r) = @_; +# $r->log_debug(__PACKAGE__ . "->dispatch_index()"); - $r->content_type('text/plain'); - $r->print(__PACKAGE__ . "->dispatch_index()"); - return Apache2::Const::OK; -} +# $r->content_type('text/plain'); +# $r->print(__PACKAGE__ . "->dispatch_index()"); +# return Apache2::Const::OK; +#} sub dispatch_baz { my ($class, $r) = @_; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <phr...@us...> - 2006-06-06 06:30:08
|
Revision: 37 Author: phred_moyer Date: 2006-06-05 23:30:00 -0700 (Mon, 05 Jun 2006) ViewCVS: http://svn.sourceforge.net/apache-dispatch/?rev=37&view=rev Log Message: ----------- Test for filtering on mod_perl 1. Modified Paths: -------------- trunk/t/03filter.t Added Paths: ----------- trunk/eg/Foo/Filter.pm Added: trunk/eg/Foo/Filter.pm =================================================================== --- trunk/eg/Foo/Filter.pm (rev 0) +++ trunk/eg/Foo/Filter.pm 2006-06-06 06:30:00 UTC (rev 37) @@ -0,0 +1,26 @@ +package Apache::Foo::Filter; + +use strict; +use warnings FATAL => 'all'; + +sub handler { + my $r = shift; + + $r->log->debug("Filtering response"); + $r->send_http_header(); + + $r = $r->filter_register; + + my $fh = $r->filter_input; + + while (<$fh>) { + $r->log->debug("Filtering data $_"); + # remove the underscores + s/_//g; + $r->log->debug("Filtered data $_"); + + print; + } +} + +1; \ No newline at end of file Modified: trunk/t/03filter.t =================================================================== --- trunk/t/03filter.t 2006-06-06 06:28:49 UTC (rev 36) +++ trunk/t/03filter.t 2006-06-06 06:30:00 UTC (rev 37) @@ -1,14 +1,24 @@ use strict; use warnings FATAL => 'all'; -use Apache::Test; +use Apache::Test qw(-withtestmore); use Apache::TestRequest; -plan tests => 1, \&have_lwp; +# figure out what version we have - I don't like this method but it works +my $httpd = Apache::Test::vars('httpd'); +my $version = `$httpd -v`; -my $url = '/filtered/Bar/good'; +if ($version =~ m/Apache\/2/) { + plan skip_all => "Filter test irrelevant on mod_perl2"; +} +else { + plan tests => 2, \&have_lwp; +} +my $url = '/filtered/foo'; + eval { require Apache::Filter }; -ok GET_OK $url; - +my $res = GET $url; +ok($res->is_success); +ok($res->content =~ m/dispatchfoo/i); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <phr...@us...> - 2006-06-06 06:28:53
|
Revision: 36 Author: phred_moyer Date: 2006-06-05 23:28:49 -0700 (Mon, 05 Jun 2006) ViewCVS: http://svn.sourceforge.net/apache-dispatch/?rev=36&view=rev Log Message: ----------- - make sure we have LWP::UserAgent for Apache::Test. The docs indicate that it can function without LWP::UA but I'm seeing some odd results which I will investigate later. Modified Paths: -------------- trunk/Makefile.PL Modified: trunk/Makefile.PL =================================================================== --- trunk/Makefile.PL 2006-06-03 07:10:38 UTC (rev 35) +++ trunk/Makefile.PL 2006-06-06 06:28:49 UTC (rev 36) @@ -10,7 +10,8 @@ print STDERR "Using mod_perl/$mp_ver\n\n"; -my %prereq = ('Apache::Test' => "1.23"); +my %prereq = ('Apache::Test' => "1.23", + 'LWP::UserAgent' => 0); my %makefile_params = ( 'VERSION' => '0.10', This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <phr...@us...> - 2006-06-03 07:10:46
|
Revision: 35 Author: phred_moyer Date: 2006-06-03 00:10:38 -0700 (Sat, 03 Jun 2006) ViewCVS: http://svn.sourceforge.net/apache-dispatch/?rev=35&view=rev Log Message: ----------- - Pre, Post, Error tests passing - Setup for filter testing - use $class instead of __PACKAGE__ to make test libs scalable. Modified Paths: -------------- trunk/lib/Apache/Dispatch/Util.pm trunk/lib/Apache/Dispatch.pm trunk/lib/Apache2/Dispatch.pm trunk/t/01plain.t trunk/t/conf/extra.last.conf.in trunk/t/lib/Apache/Foo.pm trunk/t/lib/Apache2/Foo/Bar.pm trunk/t/lib/Apache2/Foo.pm Added Paths: ----------- trunk/t/02extras.t trunk/t/03filter.t Removed Paths: ------------- trunk/t/extras.t trunk/t/filter.t Modified: trunk/lib/Apache/Dispatch/Util.pm =================================================================== --- trunk/lib/Apache/Dispatch/Util.pm 2006-05-23 03:42:16 UTC (rev 34) +++ trunk/lib/Apache/Dispatch/Util.pm 2006-06-03 07:10:38 UTC (rev 35) @@ -318,13 +318,13 @@ my ($r, $prefix, $newloc, $log, $debug) = @_; my $uri = $r->uri; + + my $location; - my $location; - # change all the / to :: (my $class_and_method = $r->uri) =~ s!/!::!g; - - if ($newloc) { + + if ($newloc) { $log->info("\tmodifying location from ", $r->location, " to $newloc") if $debug > 1; ($location = $newloc) =~ s!/!::!g; @@ -381,7 +381,9 @@ #--------------------------------------------------------------------- my $pkg = shift; - my ($object, $method, $autoload, $log, $debug) = @_; + require Data::Dumper; + + my ($object, $method, $autoload, $log, $debug) = @_; my $class = ref($object); Modified: trunk/lib/Apache/Dispatch.pm =================================================================== --- trunk/lib/Apache/Dispatch.pm 2006-05-23 03:42:16 UTC (rev 34) +++ trunk/lib/Apache/Dispatch.pm 2006-06-03 07:10:38 UTC (rev 35) @@ -485,7 +485,8 @@ Off - do not use Apache::Filter (Default) DispatchDebug - Set DispatchDebug to 1 or 2 to control the verbosity of debug statements. + Set DispatchDebug to 1 or 2 to control the verbosity of + debug statements. =head1 SPECIAL CODING GUIDELINES Modified: trunk/lib/Apache2/Dispatch.pm =================================================================== --- trunk/lib/Apache2/Dispatch.pm 2006-05-23 03:42:16 UTC (rev 34) +++ trunk/lib/Apache2/Dispatch.pm 2006-06-03 07:10:38 UTC (rev 35) @@ -211,15 +211,15 @@ foreach my $extra (@extras) { if ($extra eq "PRE") { $prehandler = - __PACKAGE__->_check_dispatch($object, "pre_dispatch", $autoload, $log); + __PACKAGE__->_check_dispatch($object, "pre_dispatch", $autoload, $log, $debug); } elsif ($extra eq "POST") { $posthandler = - __PACKAGE__->_check_dispatch($object, "post_dispatch", $autoload, $log); + __PACKAGE__->_check_dispatch($object, "post_dispatch", $autoload, $log, $debug); } elsif ($extra eq "ERROR") { $errorhandler = - __PACKAGE__->_check_dispatch($object, "error_dispatch", $autoload, $log); + __PACKAGE__->_check_dispatch($object, "error_dispatch", $autoload, $log, $debug); } } Modified: trunk/t/01plain.t =================================================================== --- trunk/t/01plain.t 2006-05-23 03:42:16 UTC (rev 34) +++ trunk/t/01plain.t 2006-06-03 07:10:38 UTC (rev 35) @@ -8,7 +8,7 @@ # Test Apache2::Foo->dispatch_index my $uri = '/plain'; -ok GET_OK $uri; +ok(GET_OK $uri, 'test passed'); # Test Apache2::Foo->dispatch_foo $uri = '/plain/foo'; Copied: trunk/t/02extras.t (from rev 32, trunk/t/extras.t) =================================================================== --- trunk/t/02extras.t (rev 0) +++ trunk/t/02extras.t 2006-06-03 07:10:38 UTC (rev 35) @@ -0,0 +1,19 @@ +use strict; +use warnings FATAL => 'all'; + +use Apache::Test; +use Apache::TestRequest; + +plan tests => 5, \&have_lwp; + +my $uri = '/extras'; +my $res = GET $uri; +ok $res->code == 200; +ok $res->content =~ m/post_dispatch/; +ok $res->content =~ m/pre_dispatch/; + +$uri = '/extras/bad'; +$res = GET $uri; +ok $res->code == 200; +ok $res->content =~ m/Yikes(.*?)dispatch_error/i; + Copied: trunk/t/03filter.t (from rev 32, trunk/t/filter.t) =================================================================== --- trunk/t/03filter.t (rev 0) +++ trunk/t/03filter.t 2006-06-03 07:10:38 UTC (rev 35) @@ -0,0 +1,14 @@ +use strict; +use warnings FATAL => 'all'; + +use Apache::Test; +use Apache::TestRequest; + +plan tests => 1, \&have_lwp; + +my $url = '/filtered/Bar/good'; + +eval { require Apache::Filter }; + +ok GET_OK $url; + Modified: trunk/t/conf/extra.last.conf.in =================================================================== --- trunk/t/conf/extra.last.conf.in 2006-05-23 03:42:16 UTC (rev 34) +++ trunk/t/conf/extra.last.conf.in 2006-06-03 07:10:38 UTC (rev 35) @@ -26,7 +26,6 @@ DispatchRequire On DispatchExtras Pre Post DispatchDebug 2 - <IfDefine APACHE2> DispatchPrefix Apache2::Foo PerlResponseHandler Apache2::Dispatch Apache2::Foo::Filter @@ -35,15 +34,13 @@ DispatchPrefix Apache::Foo PerlHandler Apache::Dispatch Apache::Foo::Filter </IfDefine> - </Location> <Location /extras> SetHandler perl-script DispatchRequire On - DispatchExtras Pre Error + DispatchExtras Pre Post Error DispatchDebug 2 - <IfDefine APACHE2> DispatchPrefix Apache2::Foo PerlResponseHandler Apache2::Dispatch @@ -52,7 +49,6 @@ DispatchPrefix Apache::Foo PerlHandler Apache::Dispatch </IfDefine> - </Location> <Location /oo> @@ -61,7 +57,6 @@ DispatchAUTOLOAD On DispatchISA Foo::Parent DispatchDebug 2 - <IfDefine APACHE2> DispatchPrefix Apache2::Foo PerlResponseHandler Apache2::Dispatch Deleted: trunk/t/extras.t =================================================================== --- trunk/t/extras.t 2006-05-23 03:42:16 UTC (rev 34) +++ trunk/t/extras.t 2006-06-03 07:10:38 UTC (rev 35) @@ -1,15 +0,0 @@ -use strict; -use warnings FATAL => 'all'; - -use Apache::Test; -use Apache::TestRequest; - -plan tests => 2, \&have_lwp; - -my $url = '/extras/Bar/pre'; - -ok GET_OK $url; - -$url = '/extras/Bar/bad'; - -ok GET_OK $url; Deleted: trunk/t/filter.t =================================================================== --- trunk/t/filter.t 2006-05-23 03:42:16 UTC (rev 34) +++ trunk/t/filter.t 2006-06-03 07:10:38 UTC (rev 35) @@ -1,14 +0,0 @@ -use strict; -use warnings FATAL => 'all'; - -use Apache::Test; -use Apache::TestRequest; - -plan tests => 1, \&have_lwp; - -my $url = '/filtered/Bar/good'; - -eval { require Apache::Filter }; - -skip 1 GET_OK $url; - Modified: trunk/t/lib/Apache/Foo.pm =================================================================== --- trunk/t/lib/Apache/Foo.pm 2006-05-23 03:42:16 UTC (rev 34) +++ trunk/t/lib/Apache/Foo.pm 2006-06-03 07:10:38 UTC (rev 35) @@ -1,51 +1,56 @@ package Apache::Foo; use Apache::Constants qw( OK SERVER_ERROR ); + use strict; +use warnings; sub dispatch_foo { - my $class = shift; - my $r = shift; - $r->log->debug(__PACKAGE__ . "->dispatch_foo()"); + my ($class, $r) = @_; + $r->log->debug("$class->dispatch_foo()"); $r->send_http_header('text/plain'); - $r->print(__PACKAGE__ . "->dispatch_foo()"); + $r->print("$class->dispatch_foo()"); return OK; } -sub dispatch_uhoh { +sub dispatch_bad { my ($class, $r) = @_; - $r->log->debug(__PACKAGE__ . "->dispatch_bar()"); + $r->log->debug("$class->dispatch_bad()"); return SERVER_ERROR; } sub pre_dispatch { my ($class, $r) = @_; - $r->log->debug(__PACKAGE__ . "->pre_dispatch()"); + $r->log->debug("$class->pre_dispatch()"); + + $r->send_http_header('text/plain'); + $r->print("$class->pre_dispatch()"); } sub post_dispatch { my ($class, $r) = @_; - $r->log->debug(__PACKAGE__ . "->post_dispatch()"); - $r->print($Apache::Foo::output); + $r->log->debug("$class->post_dispatch()"); + $r->print("$class->post_dispatch()"); + #$r->print($Apache::Foo::output); } sub error_dispatch { - my $class = shift; - my $r = shift; - $r->send_http_header('text/plain'); - $r->print("Yikes! Foo->dispatch_error()"); - $r->log->error("Yikes! " . __PACKAGE__ . "->dispatch_error()"); + my ($class, $r) = @_; + $r->log->error("Yikes! $class->dispatch_error()"); + + $r->send_http_header('text/plain'); + $r->print("Yikes! $class->dispatch_error()"); return OK; } sub dispatch_index { - my $class = shift; - my $r = shift; - $r->send_http_header('text/plain'); - $r->print(__PACKAGE__ . "->dispatch_index()"); - $r->log->debug(__PACKAGE__ . "->dispatch_index()"); + my ($class, $r) = @_; + $r->log->debug("$class->dispatch_index()"); + + $r->send_http_header('text/plain'); + $r->print("$class->dispatch_index()"); return OK; } Modified: trunk/t/lib/Apache2/Foo/Bar.pm =================================================================== --- trunk/t/lib/Apache2/Foo/Bar.pm 2006-05-23 03:42:16 UTC (rev 34) +++ trunk/t/lib/Apache2/Foo/Bar.pm 2006-06-03 07:10:38 UTC (rev 35) @@ -11,8 +11,7 @@ sub dispatch_index { # test calls to /Bar/index or / - my $self = shift; - my $r = shift; + my ($class, $r) = @_; $r->log_debug(__PACKAGE__ . "->dispatch_index()"); $r->content_type('text/plain'); @@ -31,10 +30,9 @@ } sub post_dispatch { - my $self = shift; - my $r = shift; + my ($self, $r) = @_; # delay printing headers until all processing is done - $r->content_type('text/plain'); + #$r->content_type('text/plain'); $r->print($Apache2::Foo::Foo::output); $r->log->debug(__PACKAGE__ . "->post_dispatch()"); } Modified: trunk/t/lib/Apache2/Foo.pm =================================================================== --- trunk/t/lib/Apache2/Foo.pm 2006-05-23 03:42:16 UTC (rev 34) +++ trunk/t/lib/Apache2/Foo.pm 2006-06-03 07:10:38 UTC (rev 35) @@ -7,45 +7,47 @@ sub dispatch_foo { my ($class, $r) = @_; - $r->log->debug(__PACKAGE__ . "->dispatch_foo()"); + $r->log->debug("$class->dispatch_foo()"); $r->content_type('text/plain'); - $r->print(__PACKAGE__ . "->dispatch_foo()"); + $r->print("$class->dispatch_foo()"); return Apache2::Const::OK; } -sub dispatch_uhoh { +sub dispatch_bad { my ($class, $r) = @_; + $r->log->debug("$class->dispatch_bad()"); - $r->log->debug(__PACKAGE__ . "->dispatch_uhoh()"); return Apache2::Const::SERVER_ERROR; } sub pre_dispatch { my ($class, $r) = @_; - $r->log->debug(__PACKAGE__ . "->pre_dispatch()"); + $r->log->debug("$class->pre_dispatch()"); + $r->print("$class->pre_dispatch"); } sub post_dispatch { my ($class, $r) = @_; - $r->log->debug(__PACKAGE__ . "->post_dispatch()"); + $r->log->debug("$class->post_dispatch()"); + $r->print("$class->post_dispatch"); } sub error_dispatch { my ($class, $r) = @_; - $r->log->debug(__PACKAGE__ . "->error_dispatch()"); + $r->log->debug("$class->error_dispatch()"); $r->content_type('text/plain'); - $r->print("Yikes! " . __PACKAGE__ . "->dispatch_error()"); + $r->print("Yikes! $class->dispatch_error()"); return Apache2::Const::OK; } sub dispatch_index { my ($class, $r) = @_; - $r->log->debug(__PACKAGE__ . "->dispatch_index()"); + $r->log->debug("$class->dispatch_index()"); $r->content_type('text/plain'); - $r->print(__PACKAGE__ . "->dispatch_index()"); + $r->print("$class->dispatch_index()"); return Apache2::Const::OK; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <phr...@us...> - 2006-05-23 03:42:20
|
Revision: 34 Author: phred_moyer Date: 2006-05-22 20:42:16 -0700 (Mon, 22 May 2006) ViewCVS: http://svn.sourceforge.net/apache-dispatch/?rev=34&view=rev Log Message: ----------- - Add a \n Modified Paths: -------------- trunk/test.pl Modified: trunk/test.pl =================================================================== --- trunk/test.pl 2006-05-23 03:41:21 UTC (rev 33) +++ trunk/test.pl 2006-05-23 03:42:16 UTC (rev 34) @@ -1,2 +1,2 @@ -print "you must have Apache-Test to run the test suite..."; +print "you must have Apache-Test to run the test suite...\n"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <phr...@us...> - 2006-05-23 03:41:26
|
Revision: 33 Author: phred_moyer Date: 2006-05-22 20:41:21 -0700 (Mon, 22 May 2006) ViewCVS: http://svn.sourceforge.net/apache-dispatch/?rev=33&view=rev Log Message: ----------- - This lives in lib/Apache/ now. Removed Paths: ------------- trunk/Dispatch.pm Deleted: trunk/Dispatch.pm =================================================================== --- trunk/Dispatch.pm 2006-05-22 06:20:02 UTC (rev 32) +++ trunk/Dispatch.pm 2006-05-23 03:41:21 UTC (rev 33) @@ -1,924 +0,0 @@ -package Apache::Dispatch; -# $Id: Dispatch.pm,v 1.34 2002/12/02 19:29:26 geoff Exp $ - -#--------------------------------------------------------------------- -# -# usage: PerlHandler Apache::Dispatch -# -#--------------------------------------------------------------------- - -use mod_perl 1.2401; -use Apache::Constants qw(OK DECLINED SERVER_ERROR); -use Apache::Log; -use strict; - -$Apache::Dispatch::VERSION = '0.10'; -$Apache::Dispatch::PUREPERL = 'PUREPERL'; # set during perl Makefile.PL - - -# create global hash to hold the modification times of the modules -my %stat = (); - -if ($Apache::Dispatch::PUREPERL == 0 ) { - require Apache::ModuleConfig; - require DynaLoader; - @Apache::Dispatch::ISA = qw(DynaLoader); - Apache::Dispatch->bootstrap($Apache::Dispatch::VERSION); -} - -# set debug level -# 0 - messages at info or debug log levels -# 1 - verbose output at info or debug log levels -# 2 - really verbose output at info or debug log levels -# this is rapidly becoming deprecated -$Apache::Dispatch::DEBUG = 0; - -sub handler { -#--------------------------------------------------------------------- -# initialize request object and variables -#--------------------------------------------------------------------- - - my $r = shift; - - my $dcfg; - if ($Apache::Dispatch::PUREPERL == 0) { - $dcfg=Apache::ModuleConfig->get($r,__PACKAGE__); - } else { - $dcfg=get_pureperl_config($r); - } - - my $filter = $dcfg->{_filter} || - $r->dir_config('Filter') || - 0; - - my $debug = defined $dcfg->{_debug} ? - $dcfg->{_debug} : - $Apache::Dispatch::DEBUG; - - my $autoload = $dcfg->{_autoload}; - - my $stat = $dcfg->{_stat}; - - my $prefix = $dcfg->{_prefix}; - - my $uppercase = $dcfg->{_uppercase}; - - my $new_location = $dcfg->{_newloc}; - - my $require = $dcfg->{_require}; - - my @parents = $dcfg->{_isa} ? @{$dcfg->{_isa}} : (); - - my @extras = $dcfg->{_extras} ? @{$dcfg->{_extras}} : (); - - my $log = $r->server->log; - - my $uri = $r->uri; - - my ($prehandler, $posthandler, $errorhandler, $rc); - -#--------------------------------------------------------------------- -# do some preliminary stuff... -#--------------------------------------------------------------------- - - $log->info("Using Apache::Dispatch") if $debug > 0; - - # redefine $r as necessary for Apache::Filter 1.013 and above - if ($filter) { - $log->info("\tregistering handler with Apache::Filter") - if $debug > 1; - - # in case we used DispatchFilter directive instead, make sure - # that other filters in the chain recognize us... - $r->dir_config->set(Filter => 'On'); - - $r = $r->filter_register; - $log = $r->server->log; - } - - $log->info("\tchecking $uri for possible dispatch...") - if $debug; - - # if the uri contains any characters we don't like, bounce... - # is this necessary? - if ($uri =~ m![^\w/-]!) { - $log->info("\t$uri has bogus characters...") - if $debug; - $log->info("Exiting Apache::Dispatch"); - return DECLINED; - } - - if ($debug > 1) { - $log->info("\tapplying the following dispatch rules:", - "\n\t\tDispatchPrefix: ", $prefix, - "\n\t\tDispatchUpperCase: ", $uppercase, - "\n\t\tDispatchStat: ", $stat, - "\n\t\tDispatchFilter: ", $filter, - "\n\t\tDispatchDebug: ", $debug, - "\n\t\tDispatchLocation: ", - $new_location ? $new_location : "Unaltered", - "\n\t\tDispatchAUTOLOAD: ", $autoload, - "\n\t\tDispatchRequire: ", $require, - "\n\t\tDispatchExtras: ", - (@extras ? (join ' ', @extras) : "None"), - "\n\t\tDispatchISA: ", - (@parents ? (join ' ', @parents) : "None"), - ); - } - -#--------------------------------------------------------------------- -# create the new object -#--------------------------------------------------------------------- - - my ($class, $method) = _translate_uri($r, $prefix, $new_location, - $log, $debug); - - unless ($class && $method) { - $log->info("\tclass and method could not be discovered") - if $debug; - $log->info("Exiting Apache::Dispatch") if $debug > 0; - return DECLINED; - } - - if ($uppercase) { - $class=~s/::([a-z])/::\U$1/g; - } - - my $object = {}; - - bless $object, $class; - -#--------------------------------------------------------------------- -# set parent classes for DispatchISA -#--------------------------------------------------------------------- - - if (@parents) { - $rc = _set_ISA($class, $log, $debug, @parents); - - unless ($rc) { - $log->error("\tDispatchISA did not return successfully!"); - $log->info("Exiting Apache::Dispatch"); - return DECLINED; - } - } - -#--------------------------------------------------------------------- -# require the module if DispatchRequire On -#--------------------------------------------------------------------- - - if ($require) { - $log->info("\tattempting to require $class...") - if $debug > 1; - - eval "require $class"; - - if ($@) { - $log->warn("\tcould not require $class: $@"); - $log->info("Exiting Apache::Dispatch"); - return DECLINED; - } - else { - $log->info("\t$class required successfully") - if $debug > 1; - } - } - -#--------------------------------------------------------------------- -# reload the module if DispatchStat On or ISA -#--------------------------------------------------------------------- - - if ($stat eq "ON") { - $rc = _stat($class, $log, $debug); - - unless ($rc) { - $log->error("\tDispatchStat did not return successfully!"); - $log->info("Exiting Apache::Dispatch"); - return DECLINED; - } - } - elsif ($stat eq "ISA") { - $rc = _recurse_stat($class, $log, $debug); - - unless ($rc) { - $log->error("\tDispatchStat did not return successfully!"); - $log->info("Exiting Apache::Dispatch"); - return DECLINED; - } - } - -#--------------------------------------------------------------------- -# see if the handler is a valid method -# if not, decline the request -#--------------------------------------------------------------------- - - my $handler = _check_dispatch($object, $method, $autoload, - $log, $debug); - - if ($handler) { - $log->info("\t$uri was translated into $class->$method") - if $debug; - } - else { - $log->info("\t$uri did not result in a valid method") - if $debug; - $log->info("Exiting Apache::Dispatch"); - return DECLINED; - } - -#--------------------------------------------------------------------- -# since the uri is dispatchable, check each of the extras -#--------------------------------------------------------------------- - foreach my $extra (@extras) { - if ($extra eq "PRE") { - $prehandler = _check_dispatch($object, "pre_dispatch", - $autoload, $log, $debug); - } - elsif ($extra eq "POST") { - $posthandler = _check_dispatch($object, "post_dispatch", - $autoload, $log, $debug); - } - elsif ($extra eq "ERROR") { - $errorhandler = _check_dispatch($object, "error_dispatch", - $autoload, $log, $debug); - } - } - -#--------------------------------------------------------------------- -# run each of the enabled methods, ignoring pre and post errors -#--------------------------------------------------------------------- - - eval { $object->$prehandler($r) } if $prehandler; - - eval { $rc = $object->$handler($r) }; - - if ($errorhandler && ($@ || $rc != OK)) { - # if the error handler dies we want to catch it, so don't eval - $rc = $object->$errorhandler($r, $@, $rc); - } - elsif ($@) { - $log->error("$class->$method died: $@"); - $rc = SERVER_ERROR; - } - - eval { $object->$posthandler($r) } if $posthandler; - -#--------------------------------------------------------------------- -# wrap up... -#--------------------------------------------------------------------- - - $log->info("\tApache::Dispatch is returning $rc") - if $debug; - - $log->info("Exiting Apache::Dispatch"); - - return $rc; -} - - -#********************************************************************* -# the below methods are not part of the external API -#********************************************************************* - -sub _translate_uri { -#--------------------------------------------------------------------- -# take the uri and return a class and method -# this method is for internal use only -#--------------------------------------------------------------------- - - my ($r, $prefix, $newloc, $log, $debug) = @_; - - my $uri = $r->uri; - - my $location; - - # change all the / to :: - (my $class_and_method = $r->uri) =~ s!/!::!g; - - if ($newloc) { - $log->info("\tmodifying location from ", $r->location, - " to $newloc") - if $debug > 1; - ($location = $newloc) =~ s!/!::!g; - } - else { - ($location = $r->location) =~ s!/!::!g; - } - - # strip off the leading and trailing :: if any - $class_and_method =~ s/^::|::$//g; - $location =~ s/^::|::$//g; - - # substitute the prefix for the location - # <Location /> is a special case that we can deal with - # (but not advertise :) - my $times; - - if ($location) { - $times = $class_and_method =~ s/^\Q$location/$prefix/e; - } - else { - # <Location /> - $prefix .= "::"; - $times = $class_and_method =~ s/^/$prefix/e; - } - - unless ($times) { - $log->info("\tLocation substitution failed - uri not translated") - if $debug > 1; - - return (undef, undef); - } - - my ($class, $method); - - if ($prefix eq $class_and_method) { - $method = "dispatch_index"; - $class = $prefix; - } - else { - ($class, $method) = $class_and_method =~ m/(.*)::(.*)/; - $method = "dispatch_$method"; - } - - return ($class, $method); -} - -sub _check_dispatch { -#--------------------------------------------------------------------- -# see if class->method() is a valid call -# this method is for internal use only -#--------------------------------------------------------------------- - - my ($object, $method, $autoload, $log, $debug) = @_; - - my $class = ref($object); - - my $coderef; - - $log->info("\tchecking the validity of $class->$method...") - if $debug > 1; - - if ($autoload) { - $coderef = $object->can($method) || $object->can("AUTOLOAD"); - } else { - $coderef = $object->can($method); - } - - if ($coderef && $debug > 1) { - $log->info("\t$class->$method is a valid method call"); - } elsif ($debug > 1) { - $log->info("\t$class->$method is not a valid method call"); - } - - return $coderef; -} - -sub _stat { -#--------------------------------------------------------------------- -# stat and reload the module if it has changed... -# this method is for internal use only -#--------------------------------------------------------------------- - - my ($class, $log, $debug) = @_; - - (my $module = $class) =~ s!::!/!g; - - $module .= ".pm"; - - $stat{$module} = $^T unless $stat{$module}; - - if ($INC{$module}) { - $log->info("\tchecking $module for reload in pid $$...") - if $debug > 1; - - my $mtime = (stat $INC{$module})[9]; - - unless (defined $mtime && $mtime) { - $log->warn("Apache::Dispatch cannot find $module!"); - return 1; - } - - if ( $mtime > $stat{$module} ) { - # turn off warnings for this bit... - local $^W; - - delete $INC{$module}; - eval { require $module }; - - if ($@) { - $log->error("Apache::Dispatch: $module failed reload! $@"); - return undef; - } - elsif ($debug) { - $log->info("\t$module reloaded") - } - $stat{$module} = $mtime; - } - else { - $log->info("\t$module not modified") - if $debug > 1; - } - } - else { - $log->warn("Apache::Dispatch: $module not in \%INC!"); - } - - return 1; -} - -sub _recurse_stat { -#--------------------------------------------------------------------- -# recurse through all the parent classes of the current class -# and call _stat on each -# this method is for internal use only -#--------------------------------------------------------------------- - - my ($class, $log) = @_; - - my $rc = _stat($class, $log); - - return undef unless $rc; - - # turn off strict here so we can get at the class @ISA - no strict 'refs'; - - foreach my $package (@{"${class}::ISA"}) { - $rc = _recurse_stat($package, $log); - last unless $rc; - } - - return $rc; -} - -sub _set_ISA { -#--------------------------------------------------------------------- -# set the ISA array for the class -# this method is for internal use only -#--------------------------------------------------------------------- - - my ($class, $log, $debug, @parents) = @_; - - # turn off strict here so we can get at the class @ISA - no strict 'refs'; - - if ($debug > 1) { - $log->info("\t\@ISA for $class currently contains ", - (join ", ", @{"${class}::ISA"})); - $log->info("\tabout to merge ", - (join ", ", @parents)); - } - - # only add classes to @ISA if they are not there already - my %seen; - - @{"${class}::ISA"} = grep !$seen{$_}++, - (@{"${class}::ISA"}, @parents); - - return 1; -} -#--------------------------------------------------------------------- -# Pure Perl configuration methods -#--------------------------------------------------------------------- - -sub get_pureperl_config { - my $r=shift; - my $cfg={}; - no strict 'refs'; - foreach my $key (qw(DispatchPrefix DispatchExtras DispatchStat DispatchAUTOLOAD DispatchDebug DispatchISA DispatchLocation DispatchRequire DispatchFilter DispatchUpperCase)) { - my $arg=$r->dir_config($key); - next unless $arg; - &$key($cfg,undef,$arg); - } - return $cfg; -} - -#--------------------------------------------------------------------- -# Apache configuration methods -#--------------------------------------------------------------------- - -sub _new { - return bless {}, shift; -} - -sub DIR_CREATE { - my $class = shift; - my $self = $class->_new; - - $self->{_stat} = "Off"; # no reloading by default - $self->{_autoload} = 0; # no autloading by default - $self->{_require} = 0; # no require()ing by default - -# warn "inside DIR_CREATE"; - return $self; -} - -sub DIR_MERGE { - my ($parent, $current) = @_; - my %new = (%$parent, %$current); - -# warn "inside DIR_MERGE"; - return bless \%new, ref($parent); -} - -sub DispatchLocation ($$$) { - my ($cfg, $parms, $arg) = @_; - - $cfg->{_newloc} = $arg; -} - -sub DispatchPrefix ($$$) { - my ($cfg, $parms, $arg) = @_; - - $cfg->{_prefix} = $arg; -} - -sub DispatchExtras ($$@) { - my ($cfg, $parms, $arg) = @_; - - if ($arg =~ m/^(Pre|Post|Error)$/i) { - push @{$cfg->{_extras}}, uc($arg) - unless grep /$arg/i, @{$cfg->{_extras}}; - } - else { - die "Invalid DispatchExtra $arg!"; - } -} - -sub DispatchISA ($$@) { - my ($cfg, $parms, $arg) = @_; - - push @{$cfg->{_isa}}, $arg - unless grep /$arg/, @{$cfg->{_isa}}; -} - -sub DispatchStat ($$$) { - my ($cfg, $parms, $arg) = @_; - - if ($arg =~ m/^(On|Off|ISA)$/i) { - $cfg->{_stat} = uc($arg); - } - else { - die "Invalid DispatchStat $arg!"; - } -} - -sub DispatchRequire ($$$) { - my ($cfg, $parms, $arg) = @_; - - $cfg->{_require} = $arg; -} - -sub DispatchFilter ($$$) { - my ($cfg, $parms, $arg) = @_; - - $cfg->{_filter} = $arg; -} - -sub DispatchAUTOLOAD ($$$) { - my ($cfg, $parms, $arg) = @_; - - $cfg->{_autoload} = $arg; -} - -sub DispatchDebug ($$$) { - my ($cfg, $parms, $arg) = @_; - - if ($arg =~ m/[0-9]/) { - $cfg->{_debug} = $arg; - } - else { - die "Invalid DispatchDebug $arg!"; - } -} - -sub DispatchUpperCase ($$$) { - my ($cfg, $parms, $arg) = @_; - - $cfg->{_uppercase} = $arg; -} - -1; - -__END__ - -=head1 NAME - -Apache::Dispatch - call PerlHandlers with the ease of Registry scripts - -=head1 SYNOPSIS - -httpd.conf: - - PerlModule Apache::Dispatch - PerlModule Bar - - DispatchExtras Pre Post Error - DispatchStat On - DispatchISA "My::Utils" - DispatchAUTOLOAD Off - - <Location /Foo> - SetHandler perl-script - PerlHandler Apache::Dispatch - - DispatchPrefix Bar - DispatchFilter Off - </Location> - -=head1 DESCRIPTION - -Apache::Dispatch translates $r->uri into a class and method and runs -it as a PerlHandler. Basically, this allows you to call PerlHandlers -as you would Regsitry scripts without having to load your httpd.conf -with a slurry of <Location> tags. - -=head1 EXAMPLE - - in httpd.conf - - PerlModule Apache::Dispatch - PerlModule Bar - - <Location /Foo> - SetHandler perl-script - PerlHandler Apache::Dispatch - - DispatchPrefix Bar - </Location> - - in browser: - http://localhost/Foo/baz - - the results are the same as if your httpd.conf looked like: - <Location /Foo> - SetHandler perl-script - PerlHandler Bar->dispatch_baz - </Location> - -but with the additional security of protecting the class name from -the browser and keeping the method name from being called directly. -Because any class under the Bar:: hierarchy can be called, one -<Location> directive is able to handle all the methods of Bar, -Bar::Baz, etc... - -=head1 CONFIGURATION DIRECTIVES - - DispatchPrefix - The base class to be substituted for the $r->location part of the - uri. - - DispatchLocation - Using Apache::Dispatch from a <Directory> directive, either - directly or from a .htaccess file, will _require_ the use of - DispatchLocation, which defines the location from which - Apache::Dispatch will start class->method() translation. - For example: - - httpd.conf - DocumentRoot /usr/local/apache/htdocs - <Directory /usr/local/apache/htdocs/> - ... - <Directory> - - .htaccess (in /usr/local/apache/htdocs/Foo) - SetHandler perl-script - PerlHandler Apache::Dispatch - DispatchPrefix Baz - DispatchLocation /Foo - - This allows a request to /Foo/Bar/biff to properly map to - Baz::Bar->biff(). - - While intended specifically for <Directory> configurations, one - could use DispatchLocation to further obscure uri translations - within <Location> sections as well by changing the part of - the uri that is substitued with your module. - - DispatchExtras - An optional list of extra processing to enable per-request. If - the main handler is not a valid method call, the request is - declined prior to the execution of any of the extra methods. - - Pre - eval()s Foo->pre_dispatch($r) prior to dispatching the - uri. The $@ of the eval is not checked in any way. - - Post - eval()s Foo->post_dispatch($r) after dispatching the - uri. The $@ of the eval is not checked in any way. - - Error - If the main handler returns other than OK then - Foo->error_dispatch($r, $@) is called and return status - of it is returned instead. Unlike the pre and post - processing routines above, error_dispatch is not wrapped - in an eval, so if it dies, the Apache::Dispatch dies, - and Apache will process the error using ErrorDocument, - custom_response(), etc. - With error_dispatch() disabled, the return status of the - the main handler is returned to the client. - - DispatchRequire - An optional directive that enables require()ing of the module that - is the result of the uri to class->method translation. This allows - your configuration to be a bit more dynamic, but also decreases - security somewhat. And don't forget that you really should be - pre-loading frequently used modules in the parent process to reduce - overhead - DispatchRequire is a directive of conveinence. - - On - require() the module - - Off - Do not require() the module (Default) - - DispatchStat - An optional directive that enables reloading of the module that is - the result of the uri to class->method translation, similar to - Apache::Registry, Apache::Reload, or Apache::StatINC. - - On - Test the called package for modification and reload on - change - - Off - Do not test or reload the package (Default) - - ISA - Test the called package, and all other packages in the - called package's @ISA, and reload on change - - DispatchAUTOLOAD - An optional directive that enables unknown methods to use - AutoLoader. It may be applied on a per-server or per-location - basis and defaults to Off. Please see the special section on - AUTOLOAD below. - - On - Allow for methods to be defined in AUTOLOAD method - - Off - Turn off search for AUTOLOAD method (Default) - - DispatchISA - An optional list of parent classes you want your dispatched class - to inherit from. - - DispatchFilter - If you have Apache::Filter 1.013 or above installed, you can take - advantage of other Apache::Filter aware modules. Please see the - section on FILTERING below. In keeping with Apache::Filter - standards, PerlSetVar Filter has the same effect as DispatchFilter - but with lower precedence. - - On - make the output of your module Apache::Filter aware - - Off - do not use Apache::Filter (Default) - - DispatchDebug - Apache::Dispatch uses $r->server->log->info() for debugging. - Verbose debugging is enabled by setting DispatchDebug to 1. - Very verbose debugging is enabled at 2. $Apache::Dispatch::DEBUG - remains for backward compatibility, but is soon to be deprecated. - To turn off all debug information set your Apache LogLevel - directive above info level. - -=head1 SPECIAL CODING GUIDELINES - -Migrating to Apache::Dispatch is relatively painless - it requires -only a few minor code changes. The good news is that once you adapt -code to work with Dispatch, it can be used as a conventional mod_perl -method handler, requiring only a few considerations. Below are a few -things that require attention. - -In the interests of security, all handler methods must be prefixed -with 'dispatch_', which is added to the uri behind the scenes. Unlike -ordinary mod_perl handlers, for Apache::Dispatch there is no default -method (with a tiny exception - see NOTES below). - -Apache::Dispatch uses object oriented calls behind the scenes. This -means that you either need to account for your handler to be called -as a method handler, such as - - sub dispatch_bar { - my $self = shift; # your class - my $r = shift; - } - -or get the Apache request object directly via - - sub dispatch_bar { - my $r = Apache->request; - } - -If you want to use the handler unmodified outside of Apache::Dispatch, -you must do three things: - - prototype your handler: - - sub dispatch_baz ($$) { - my $self = shift; - my $r = shift; - } - - change your httpd.conf entry: - - <Location /Foo> - SetHandler perl-script - PerlHandler Bar->dispatch_baz - </Location> - - pre-load your module: - PerlModule Bar - or - PerlRequire startup.pl - # where startup.pl contains - # use Bar; - -That's it - now the handler can be swapped in and out of Dispatch -without further modification. See the Eagle book on method handlers -for more details. - -=head1 FILTERING - -Apache::Dispatch provides for output filtering using Apache::Filter -1.013 and above. - - <Location /Foo> - SetHandler perl-script - PerlHandler Apache::Dispatch Apache::Compress - - DispatchPrefix Bar - DispatchFilter On - </Location> - -Your handler need do nothing special to make its output the start of -the chain - Apache::Dispatch registers itself with Apache::Filter and -hides the task from your handler. Thus, any dispatched handler is -automatically Apache::Filter ready without the need for additional -code. - -The only caveat is that you must use the request object that is passed -to the handler and not get it directly using Apache->request. - -=head1 AUTOLOAD - -Support for AUTOLOAD has been made optional, but requires special -care. Please take the time to read the camel book on using AUTOLOAD -with can() and subroutine declarations (3rd ed pp326-329). - -Basically, you declare the methods you want AUTOLOAD to capture by -name at the top of your script. This is necessary because can() -will return true if your class (or any parent class) contains an -AUTOLOAD method, but $AUTOLOAD will only be populated for declared -method calls. Hence, without a declaration you won't be able to -get at the name of the method you want to AUTOLOAD. - -DispatchISA introduced some convenience, but some headaches as well - -if you inherit from a class that uses AutoLoader then ALL method calls -are true. And as just explained, AUTOLOAD() will not know what the -called method was. This may represent a problem if you aren't aware -that, say, CGI.pm uses AutoLoader and spend a few hours trying to -figure out why all of a sudden every URL under Dispatch is bombing. -You may want to check out NEXT.pm (available from CPAN) for use in -your AUTOLOAD routines to help circumvent this partucular feature. - -If you decide to use DispatchISA it is HIGHLY SUGGESTED that you do so -with DispatchAUTOLOAD Off (which is the default behavior). - -=head1 NOTES - -If you define a dispatch_index() method calls to /Foo will default to -it. Unfortunately, this implicit translation only happens at the -highest level - calls to /Foo/Bar will translate to Foo->Bar() (that -is, unless Foo::Bar is your DispatchPrefix, in which case it will -work but /Foo/Bar/Baz will not, etc). Explicit calls to /Foo/index -follow the normal dispatch rules. - -If the uri can be dispatched but contains anything other than -[a-zA-Z0-9_/-] Apache::Dispatch declines to handle the request. - -Like everything in perl, the package names are case sensitive. - -Warnings have been left on, so if you set an invalid class with -DispatchISA you will see a message like: - Can't locate package Foo::Bar for @Bar::Baz::ISA at - .../Apache/Dispatch.pm line 277. - -This is alpha software, and as such has not been tested on multiple -platforms or environments for security, stability or other concerns. -It requires PERL_DIRECTIVE_HANDLERS=1, PERL_LOG_API=1, PERL_HANDLER=1, -and maybe other hooks to function properly. - -=head1 FEATURES/BUGS - -If a module fails reload under DispatchStat, Apache::Dispatch declines -the request. This might change to SERVER_ERROR in the future... - -=head1 SEE ALSO - -perl(1), mod_perl(1), Apache(3), Apache::Filter(3), Apache::Reload(3), -Apache::StatINC(3) - -=head1 AUTHOR - -Geoffrey Young <ge...@cp...> - -=head1 COPYRIGHT - -Copyright 2001 Geoffrey Young - all rights reserved. - -This library is free software; you can redistribute it and/or -modify it under the same terms as Perl itself. - -=cut This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |