Stas Bekman wrote:
We have a need to be able to load mp2 modules at the server startup
(e.g. APR::Error), but we are dependent on the users to load
Apache2.pm, without which mp2 modules won't be found (if installed
into Apache2/).
in the test suite or in real life?
Real Life (tm).
So here is a proposal how to solve this problem.
mod_perl will load Apache2.pm by itself, as soon as it starts
perl.
so Apache2 would be called after the interpreter is launched but before, say, a <Perl> or PerlLoadModule directive is run? that would be a requirement I would think.
That's correct.
For most people it'll just save them the need to type
PerlModule Apache2
for the moment. as people move away from mp1 the Apache2 hack will disappear. I wouldn't expect to need it at all anyplace other than development, so I would suspect that for the majority of eventual installations (1 dev box versus a production cluster) we would be cluttering @INC for no reason.
No, we won't. @INC gets modified only mp2 was installed into Apache2/ subdir(s). It will leave @INC intact otherwise.
For those who will want to adjust @INC before Apache2 is loaded (to find a different mp2), there is PerlSwitches, which must be set before perl is started. So lets say you want to load your private mp2 (installed at /home/stas/perl5/) on a system where there is already mp2 installed under /usr/lib/perl5, so your httpd.conf will look like:
LoadModule perl_module modules/mod_perl.so PerlSwitches -Mlib=/home/stas/perl5/
I'm not sure I follow how this. if your mp2 install is in /home/stas/perl5
then won't the load of APR::Error be found in @INC _before_ the -Mlib call,
therefore using a version from someplace _other_ than -Mlib?
No, APR::Error will be loaded after Apache2.pm is loaded, which is after PerlSwitches are processed.
if so, you would almost always load the wrong version (or at least not the one you thought you were pointing at with -Mlib). if not, then why not just let the users specify PerlModule Apache2 themselves without the magic?
See the top of my email. Because we can't rely on users loading Apache2 as the very first thing. Things may fail before that, and an attempt to load APR::Error may fail (which is the case right now).
So the only inconvenience it creates is that you can't do it from your startup.pl, but must use PerlSwitches. PERL5LIB env var is not applicable as it's ignored by Perl when -T is in effect.
Can anybody see any potential problems with this solution?
perhaps. once you load Apache2 @INC is forever tainted with whatever Apache2.pm finds. granted, the -Mlib statement will give the new lib priority, but it still feels a bit strange to have @INC reflect stuff I may not be interested in - for instance, would this make it more difficult to track down problems where there the -Mlib install is incomplete so perl picks mix-and-match mp2 packages from lib and lib/Apache2?
You have an exact same problem w/o having Apache2/.
I'm not convinced this is a good idea, at least not yet :). but if there is no way to work around the APR::Error thing then I think what we really need is a way to remove Apache2 entries from @INC. that way a user can completely cancel the effects of Apache2 if they want, not merely gloss over it with extra libs.
I've posted a patch to do this many moons ago: http://marc.theaimsgroup.com/?l=apache-modperl-dev&m=104865589413893&w=2
another suggestion is to make it a compile-time option, loading Apache2 by default but giving the ability to turn it off. this seems a bit cleaner than making an anti-Apache2 module or directive that people need to remember to call if they _don't_ want Apache2 messing with their @INC.
Good idea, Geoff. So if someone has previously installed into Apache2/ and reinstalling things outside Apache2/ so it'll not pick the old install.
However, I don't think there should be an ability to turn it off. If you compile mp2 with MP_INST_APACHE2=1, that should be enough to know that Apache2 is desired.
As Gozer has mentioned some time before mp1 takes a notion of PREFIX, so if someone installs things into a different PREFIX, we could make Apache2 aware of that and may be insert only Apache2/ sub-dirs for that particular prefix.
In any case we could make Apache2::import smarter to accept a PREFIX argument, so if I do:
PerlSwitches -MApache2=/home/stas/local_perl
and there is /usr/lib/perl5/.../Apache2 and /home/stas/local_perl/.../Apache2, Apache2 will push only the latter dir onto @INC.
By default it'll continue to push any Apache2/ it finds.
-- __________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
