You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by "Goehring, Chuck Mr., RCI - San Diego" <cg...@resourceconsultants.com> on 2003/03/17 22:16:43 UTC
Where do you put your stuff?
To all,
Years ago, I found a module called FindBin that at least seamed to solved many problems. I use it in mod_perl code (I'm on Win 2000) like this:
use FindBin qw($Bin);
use lib "$Bin/sims"; # Directory for specific application.
use lib "$Bin/common"; # Directory for common stuff.
Under mod_perl 2 this doesn't seam to work any more. Looking at all the stuff on perl.apache.org I figured I'd finally ask you guys these questions:
Where do you put your .pm files for application-specific code?
Which method of lib, use lib, use etc do you use, so these modules can be found.
Thanks
Chuck
Re: [mp2] adding SERVER_ROOT and SERVER_ROOT/lib/perl to @INC
Posted by Stas Bekman <st...@stason.org>.
I've committed the code that adds SERVER_ROOT and SERVER_ROOT/lib/perl to
@INC, but it's disabled if an explicit MP_COMPAT_1X=0 is passed to Makefile.PL
(it's enabled by default).
I'll document shortly what other mp1-compat features can be disabled by
passing MP_COMPAT_1X=0...
__________________________________________________________________
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
Re: [mp2] adding SERVER_ROOT and SERVER_ROOT/lib/perl to @INC
Posted by Nick Tonkin <ni...@tonkinresolutions.com>.
On Tue, 18 Mar 2003, Geoffrey Young wrote:
>
>
> Stas Bekman wrote:
> > Perrin Harkins wrote:
> >
> >> Stas Bekman wrote:
> >>
> >>> The question is, do we want to have this feature in mp2?
> >>
> >>
> >>
> >> I thought it was cool to have it automatically add a path relative to
> >> the server root, because it makes it feel more like you are writing
> >> real Apache modules, and not just CGI scripts. It's just a warm fuzzy
> >> thing really. I have no problem with dropping that feature and adding
> >> the path myself in startup.pl or httpd.conf.
> >
> >
> > I'm +0 on adding this feature. While I have never used it myself, I see
> > no harm in keeping back-compatibility with 1.0. Unless someone has a
> > reason for not having it I'll commit the patch I've posted earlier.
Is there a performance hit to having @INC include another directory (that
will not be used by many [most?] users)? If so, that's a good argument
against.
>
> in 1.0 I used it all the time and liked having it there. however, I
> suspect that doug left it out on purpose - IIRC PerlSwitches was his
> answer when this was asked before (maybe it was at a conference, I
> can't remember).
I think Doug was right. PerlSwitches is a more flexible, more perlsih and
mod_perlish way of doing it, IMO. Just needs good documentation :)
- nick
--
~~~~~~~~~~~~~~~~~~~~
Nick Tonkin {|8^)>
Re: [mp2] adding SERVER_ROOT and SERVER_ROOT/lib/perl to @INC
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
Stas Bekman wrote:
> Perrin Harkins wrote:
>
>> Stas Bekman wrote:
>>
>>> The question is, do we want to have this feature in mp2?
>>
>>
>>
>> I thought it was cool to have it automatically add a path relative to
>> the server root, because it makes it feel more like you are writing
>> real Apache modules, and not just CGI scripts. It's just a warm fuzzy
>> thing really. I have no problem with dropping that feature and adding
>> the path myself in startup.pl or httpd.conf.
>
>
> I'm +0 on adding this feature. While I have never used it myself, I see
> no harm in keeping back-compatibility with 1.0. Unless someone has a
> reason for not having it I'll commit the patch I've posted earlier.
in 1.0 I used it all the time and liked having it there. however, I
suspect that doug left it out on purpose - IIRC PerlSwitches was his
answer when this was asked before (maybe it was at a conference, I
can't remember).
anyway, I'd say do it and let purists complain later - it will make
porting that much more seamless.
--Geoff
Re: [mp2] adding SERVER_ROOT and SERVER_ROOT/lib/perl to @INC
Posted by Stas Bekman <st...@stason.org>.
Perrin Harkins wrote:
> Stas Bekman wrote:
>
>> The question is, do we want to have this feature in mp2?
>
>
> I thought it was cool to have it automatically add a path relative to
> the server root, because it makes it feel more like you are writing real
> Apache modules, and not just CGI scripts. It's just a warm fuzzy thing
> really. I have no problem with dropping that feature and adding the
> path myself in startup.pl or httpd.conf.
I'm +0 on adding this feature. While I have never used it myself, I see no
harm in keeping back-compatibility with 1.0. Unless someone has a reason for
not having it I'll commit the patch I've posted earlier.
__________________________________________________________________
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
Re: [mp2] adding SERVER_ROOT and SERVER_ROOT/lib/perl to @INC
Posted by Perrin Harkins <pe...@elem.com>.
Stas Bekman wrote:
> The question is, do we want to have this feature in mp2?
I thought it was cool to have it automatically add a path relative to
the server root, because it makes it feel more like you are writing real
Apache modules, and not just CGI scripts. It's just a warm fuzzy thing
really. I have no problem with dropping that feature and adding the
path myself in startup.pl or httpd.conf.
- Perrin
[mp2] adding SERVER_ROOT and SERVER_ROOT/lib/perl to @INC
Posted by Stas Bekman <st...@stason.org>.
Nick Tonkin wrote:
> On Mon, 17 Mar 2003, Perrin Harkins wrote:
>
>
>>Goehring, Chuck Mr., RCI - San Diego wrote:
>>
>>> Where do you put your .pm files for application-specific code?
>>
>>Under mod_perl 1, I just put them in <SERVER_ROOT>/lib/perl, which is
>>automatically added to @INC by mod_perl. Can someone confirm if this
>>still works for mp2?
>
>
> I do not believe so.
Though it is easy to add. See the patch below.
The question is, do we want to have this feature in mp2? Does it really save
someone a trouble of creating a startup file? Also, In 2.0 you don't have to
create a startup file for that, you can simply say:
PerlSwitches -I/home/httpd -I/home/httpd/lib/perl
Admittedly you will have to hardcode the document root in this case, but you
do that anyways in httpd.conf when you specify it.
Index: src/modules/perl/mod_perl.c
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/mod_perl.c,v
retrieving revision 1.157
diff -u -r1.157 mod_perl.c
--- src/modules/perl/mod_perl.c 17 Mar 2003 02:15:09 -0000 1.157
+++ src/modules/perl/mod_perl.c 18 Mar 2003 22:55:08 -0000
@@ -190,6 +190,11 @@
);
#endif
+ av_push(GvAV(PL_incgv),
+ newSVpv(ap_server_root_relative(p, ""), 0));
+ av_push(GvAV(PL_incgv),
+ newSVpv(ap_server_root_relative(p, "lib/perl"), 0));
+
if (!modperl_config_apply_PerlRequire(s, scfg, perl, p)) {
exit(1);
}
__________________________________________________________________
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
Re: Where do you put your stuff?
Posted by Nick Tonkin <ni...@tonkinresolutions.com>.
On Mon, 17 Mar 2003, Perrin Harkins wrote:
> Goehring, Chuck Mr., RCI - San Diego wrote:
> > Where do you put your .pm files for application-specific code?
>
> Under mod_perl 1, I just put them in <SERVER_ROOT>/lib/perl, which is
> automatically added to @INC by mod_perl. Can someone confirm if this
> still works for mp2?
I do not believe so. In mp2 when you do 'use Apache2();' it modifies your
@INC, but adds only <PERL_LIB>/Apache2 ... so my @INC inside my mp2 server
is:
/home/debug/perl/lib/site_perl/5.8.0/i386-freebsd/Apache2
/home/debug/perl/lib/5.8.0/i386-freebsd
/home/debug/perl/lib/5.8.0
/home/debug/perl/lib/site_perl/5.8.0/i386-freebsd
/home/debug/perl/lib/site_perl/5.8.0
/home/debug/perl/lib/site_perl
.
> Of course you can just put a "use lib" in your startup.pl, assuming that
> you are doing this for a server where you know the locations of things.
I do that anyway since I want to keep my application code separate from
the Apache/perl/mod_perl lib dirs. But that's just me. I'm a neat freak. I
used to use Partition Magic on my Windows boxes to make C: for the OS, D:
for apps, and E: for data, until I found out that Windows apps install
themselves wherever they feel like it :)
- nick
--
~~~~~~~~~~~~~~~~~~~~
Nick Tonkin {|8^)>
Re: Where do you put your stuff?
Posted by Perrin Harkins <pe...@elem.com>.
Goehring, Chuck Mr., RCI - San Diego wrote:
> Where do you put your .pm files for application-specific code?
Under mod_perl 1, I just put them in <SERVER_ROOT>/lib/perl, which is
automatically added to @INC by mod_perl. Can someone confirm if this
still works for mp2?
Of course you can just put a "use lib" in your startup.pl, assuming that
you are doing this for a server where you know the locations of things.
- Perrin