httpd-apreq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject Re: libapreq-1.2 release candidate
Date Mon, 05 May 2003 00:07:14 GMT
David Wheeler wrote:
[...]
> I just took a look at Exporter::import, and it uses both the class name 
> in the first argument in order to find the subroutines to export and the 
> caller for the namespace to import them into. I hadn't made this 
> connection before, and should have looked at import() before. The upshot 
> is that it never worked because I hadn't changed the first argument to 
> import() to 'Apache::Test' -- your example above tickled that for me. So 
> here's the best solution I can see:
> 
> sub import {
>     my $package = shift;
>     unshift @_, 'Apache::Test';
>     goto &{Apache::Test->can('import')};
> }
> 
> This way, the caller is the package that C<use>d Apache::Test (thanks to 
> the goto), and, because the first argument is 'Apache::Test', import() 
> now knows where to find the functions to actually import.

Thanks David, please check if the patch below plus the usual 
s/Apache::Test;/Apache::TestLoad;/ does the job.

>> Cool.
>>
>> Any alternative naming suggestions to TestLoad?
> 
> 
> How 'bout Apache::Tester? If it sticks, and people just use that, you 
> might eventually be able to eliminate Apache::Test and be done with this 
> problem.

But Apache::TestLoad does just this: load the suite it doesn't really do anything.

I agree that Apache::Tester is a nice replacement for Apache::Test to 
eliminate the whole collision problem without using the TestLoad trickery.
If that's the case we need to eliminate Apache::Test completely and rename it 
and the package with Apache::Tester. And hopefully convince Andreas to remove 
any traces of Apache::Test from CPAN. It'll also require messing with cvs 
repositories.

And the patch.

Index: lib/Apache/TestMM.pm
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestMM.pm,v
retrieving revision 1.25
diff -u -r1.25 TestMM.pm
--- lib/Apache/TestMM.pm	1 May 2003 06:22:35 -0000	1.25
+++ lib/Apache/TestMM.pm	5 May 2003 00:01:44 -0000
@@ -4,6 +4,7 @@
  use warnings FATAL => 'all';

  use Config;
+use Apache::TestLoad ();
  use Apache::TestConfig ();
  use Apache::TestTrace;


--- /dev/null	1970-01-01 10:00:00.000000000 +1000
+++ lib/Apache/TestLoad.pm	2003-05-05 09:50:29.000000000 +1000
@@ -0,0 +1,57 @@
+package Apache::TestLoad;
+
+use strict;
+use warnings FATAL => 'all';
+
+use File::Spec::Functions qw(catfile catdir);
+
+require Apache::Test;
+
+unless (defined $Apache::Test::VERSION) {
+    foreach (@INC) {
+        my $dir = catdir $_, "Apache";
+        next unless -d $dir;
+        opendir DIR, $dir or die "Cannot opendir $dir: $!\n";
+        my @matches = grep /^Test.pm$/, readdir DIR;
+        closedir DIR;
+        next unless @matches;
+        my $file = catfile $dir, $matches[0];
+        do $file;
+        last;
+    }
+}
+
+die "Still can't find Apache::Test"
+    unless defined defined $Apache::Test::VERSION;
+
+sub import {
+    my $package = shift;
+    unshift @_, 'Apache::Test';
+    goto &{Apache::Test->can('import')};
+}
+
+1;
+
+__END__
+
+=pod
+
+=head1 NAME
+
+Apache::TestLoad - Load the correct Apache::Test
+
+=head1 SYNOPSIS
+
+  use Apache::TestLoad;
+
+=head1 DESCRIPTION
+
+If you want to use C<Apache::Test>, you should load
+C<Apache::TestLoad> instead. This is a workaround because some case
+insensitive filesystems may load I<Apache/test.pm> instead of
+I<Apache/Test.pm> where mod_perl 1.0 is installed.
+
+Luckily we can manually walk the @INC dirs and force to load
+I<Apache/Test.pm>.
+
+=cut

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Mime
View raw message