perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Devin Teske <dte...@vicor.com>
Subject Re: Custom INC per-directory
Date Tue, 20 Oct 2009 17:53:48 GMT
Well, I was thinking I could get away with something like this...

foo's .htaccess:

<Perl>
  use ModPerl::Util;
  ModPerl::Util::unload_package(MyAuth::Authnz);
  unshift(@INC, '/modules/foo');
  push @PerlInitHandler, 'MyAuth::Authnz';
</Perl>

bar's .htaccess:

<Perl>
  use ModPerl::Util;
  ModPerl::Util::unload_package(MyAuth::Authnz);
  unshift(@INC, '/modules/bar');
  push @PerlInitHandler, 'MyAuth::Authnz';
</Perl>


Though even that has some weirdness to it and doesn't quite work right.

I wonder if ModPerl::PackageRegistry in CPAN
( http://search.cpan.org/~crakrjack/ModPerl-
PackageRegistry-0.02/lib/ModPerl/PackageRegistry.pm ) could help. It
looks to be what I want, but seems a bit strange.

I think ultimately, I may have to code some kind of dispatch module that
is called from both the production and testing trees and then that
module dynamically dispatches the call to the proper module based on the
chain of command (as in, who called it).
--
Devin





On Tue, 2009-10-20 at 19:38 +0200, Clinton Gormley wrote:
> > For example, I'd like to be able to have:
> > 
> > File 1: /usr/foo/.htaccess:
> > PerlInitHandler MyAuth::Authnz.pm
> > # We want this to load /modules/foo/MyAuth/Authnz.pm
> > 
> > 
> > File 2: /usr/bar/.htaccess:
> > PerlInitHandler MyAuth::Authnz.pm
> > # We want this to load /modules/bar/MyAuth/Authnz.pm
> 
> Think what would happen if you did this in a Perl script:
> 
> BEGIN { @INC = '/modules/foo' }
> use My::Module;
> BEGIN { @INC, '/modules/bar' }
> use My::Module;
> 
> The second use wouldn't do anything because Perl sees that it has
> already loaded My::Module.
> 
> So the only way to do what you want is to run two separate servers (or
> just use plain CGI - no mod_perl).
> 
> You're going to need to use different module names. But, if
> MyAuth::Authnz contains a lot of functionality which you need in both
> modules, then why not subclass it and put the foo/bar specific stuff
> into a module which inherits from it?
> 
> clint
> 
-- 
Cheers,
Devin Teske

-> CONTACT INFORMATION <-
Field Engineer
FIS - Vicor Business Unit
626-573-6040 Office
510-735-5650 Mobile
devin.teske@metavante.com

-> LEGAL DISCLAIMER <-
This message  contains confidential  and proprietary  information
of the sender,  and is intended only for the person(s) to whom it
is addressed. Any use, distribution, copying or disclosure by any
other person  is strictly prohibited.  If you have  received this
message in error,  please notify  the e-mail sender  immediately,
and delete the original message without making a copy.

-> END TRANSMISSION <-


Mime
View raw message