You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by Stas Bekman <st...@stason.org> on 2001/11/12 08:04:36 UTC

[patch] PerlINC implementation

this patch implements the PerlINC wrapper which does:
s/PerlSwitches -Ilib=foo/PerlINC foo/

Index: src/modules/perl/mod_perl.c
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/mod_perl.c,v
retrieving revision 1.93
diff -u -r1.93 mod_perl.c
--- src/modules/perl/mod_perl.c	2001/11/01 23:50:32	1.93
+++ src/modules/perl/mod_perl.c	2001/11/12 06:10:46
@@ -419,6 +419,7 @@
     MP_CMD_SRV_ITERATE("PerlRequire", requires, "PerlRequire"),
     MP_CMD_DIR_ITERATE("PerlOptions", options, "Perl Options"),
     MP_CMD_DIR_ITERATE("PerlInitHandler", init_handlers, "Subroutine name"),
+    MP_CMD_DIR_ITERATE("PerlINC", perl_inc, "PerlINC"),
     MP_CMD_DIR_TAKE2("PerlSetVar", set_var, "PerlSetVar"),
     MP_CMD_DIR_ITERATE2("PerlAddVar", add_var, "PerlAddVar"),
     MP_CMD_SRV_RAW_ARGS("<Perl", perl, "NOT YET IMPLEMENTED"),
Index: src/modules/perl/modperl_cmd.c
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_cmd.c,v
retrieving revision 1.14
diff -u -r1.14 modperl_cmd.c
--- src/modules/perl/modperl_cmd.c	2001/10/11 04:47:30	1.14
+++ src/modules/perl/modperl_cmd.c	2001/11/12 06:10:46
@@ -125,6 +125,15 @@
     return modperl_cmd_post_read_request_handlers(parms, mconfig, arg);
 }

+MP_CMD_SRV_DECLARE(perl_inc)
+{
+    char *newarg = apr_psprintf(parms->pool, "-Mlib=%s", arg);
+
+    MP_TRACE_d(MP_FUNC, "arg = %s\n", arg);
+    modperl_cmd_switches(parms, mconfig, newarg);
+    return NULL;
+}
+
 MP_CMD_SRV_DECLARE(perl)
 {
     return "<Perl> sections not yet implemented in modperl-2.0";
Index: src/modules/perl/modperl_cmd.h
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_cmd.h,v
retrieving revision 1.16
diff -u -r1.16 modperl_cmd.h
--- src/modules/perl/modperl_cmd.h	2001/10/11 04:47:30	1.16
+++ src/modules/perl/modperl_cmd.h	2001/11/12 06:10:46
@@ -24,6 +24,7 @@
 MP_CMD_SRV_DECLARE2(add_var);
 MP_CMD_SRV_DECLARE(options);
 MP_CMD_SRV_DECLARE(init_handlers);
+MP_CMD_SRV_DECLARE(perl_inc);
 MP_CMD_SRV_DECLARE(perl);

 #ifdef MP_COMPAT_1X
Index: t/response/TestDirective/perlrequire.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/t/response/TestDirective/perlrequire.pm,v
retrieving revision 1.3
diff -u -r1.3 perlrequire.pm
--- t/response/TestDirective/perlrequire.pm	2001/09/22 09:33:31	1.3
+++ t/response/TestDirective/perlrequire.pm	2001/11/12 06:10:47
@@ -56,10 +56,10 @@
     </IfDefine>

     # use test system's @INC
-    PerlSwitches -Mlib=@serverroot@
+    PerlINC @serverroot@
     PerlRequire "conf/modperl_startup.pl"

-    PerlSwitches -Mlib=@documentroot@/testdirective/vh
+    PerlINC @documentroot@/testdirective/vh
     PerlRequire "PerlRequireTest.pm"

     <Location /TestDirective::perlrequire>
Index: todo/possible_new_features.txt
===================================================================
RCS file: /home/cvs/modperl-2.0/todo/possible_new_features.txt,v
retrieving revision 1.11
diff -u -r1.11 possible_new_features.txt
--- todo/possible_new_features.txt	2001/10/08 17:37:51	1.11
+++ todo/possible_new_features.txt	2001/11/12 06:10:47
@@ -22,10 +22,6 @@

 - setuid/gid before running any Perl code

-- implement PerlINC (or similar) as a nicer interface for the working
-  PerlSwitches -Mlib=/home/dev1/lib/perl, to set different @INC for
-  different virtual hosts.
-
 - a possible implementation of PerlOptions +Inherit, similar to
   +Parent but which allows virtual hosts to inherit everything that
   was loaded by the main server, at the point of their definition in



_____________________________________________________________________
Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
mailto:stas@stason.org  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [patch] PerlINC implementation

Posted by Stas Bekman <st...@stason.org>.
Doug MacEachern wrote:

> On Mon, 12 Nov 2001, Stas Bekman wrote:
> 
> 
>>this patch implements the PerlINC wrapper which does:
>>s/PerlSwitches -Ilib=foo/PerlINC foo/
>>
> 
> if we add a new directive like this i think it should be a wrapper around
> what 'Perl{Set,Pass}Env PERL5LIB' would do, that is:
> 
> - unshift @INC
> - work per-directory
> 
> otherwise, i don't see the value in adding a new directive for something
> that can already be done with PerlSwitches or a 'use lib ...' in a
> PerlRequire'd file.
> 


well, I've just followed the notes in todo saying:


-- implement PerlINC (or similar) as a nicer interface for the working
-  PerlSwitches -Mlib=/home/dev1/lib/perl, to set different @INC for
-  different virtual hosts.

;)

so can you please adjust the todo item? I understood that you've planned 
on doing the 'Perl{Set,Pass}Env'.



_____________________________________________________________________
Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
mailto:stas@stason.org  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [patch] PerlINC implementation

Posted by Stas Bekman <st...@stason.org>.
> Sounds good to me, but I have a question.  If one does :
> 
> <Location /foo>
>   PerlSetINC /this/dir
> </Location>
> 
> </Location /bar>
>   PerlSetINC /this/other/dir
> </Location>
> 
> Can I assume that it would:
> 
> 1.  Populate @INC on a per-request/per-location basis ?
> 2.  Allow for changes of @INC , like if the application code fiddles
>     with it, be guaranteed that whatever is specified by PerlSetINC
>     will be in @INC for every request?


Yes.

Plus you can

PerlSetINC /common

</Location /bar>
PerlAddINC /bar/lib
</Location>

<Location /foo>
PerlAddINC /foo/lib
</Location>

so the /common will be inherited from the top level scope.


_____________________________________________________________________
Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
mailto:stas@stason.org  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [patch] PerlINC implementation

Posted by "Philippe M. Chiasson" <go...@eXtropia.com>.
On Tue, Nov 20, 2001 at 02:22:54PM +0800, Stas Bekman wrote:
> Doug MacEachern wrote:
> 
> >On Mon, 12 Nov 2001, Stas Bekman wrote:
> >
> >
> >>this patch implements the PerlINC wrapper which does:
> >>s/PerlSwitches -Ilib=foo/PerlINC foo/
> >>
> >
> >if we add a new directive like this i think it should be a wrapper 
> >around
> >what 'Perl{Set,Pass}Env PERL5LIB' would do, that is:
> >
> >- unshift @INC
> >- work per-directory
> >
> >otherwise, i don't see the value in adding a new directive for 
> >something
> >that can already be done with PerlSwitches or a 'use lib ...' in a
> >PerlRequire'd file.
> 
> 
> Now that PerlSetEnv is in place, the only missing thing is
> porting from 1.x the special handling of PERL5LIB env var in the 
> beginning of request and server startup.
> 
> I think this also should be done disregarding the value of SetupEnv, 
> 
> since it's a special variable.
> 
> Another issue is what happens if someone specifies:
> 
> PerlSetEnv Perl5LIB /foo
> and
> PerlINC /foo
> 
> in the same configuration scope. The thing about the two is that you 
> 
> cannot repeat the directives ala 'use lib' or PerlSwitches.
> 
> So may be we shouldn't endorse using 'PerlSetEnv PERL5LIB', but only 
> 
> 'PerlPassEnv PERL5LIB'. I prefer to have one convenient way to 
> mangle @INC, which satisfies needs of all. So far 'PerlSwitches 
> -Mlib=/foo' is a such, but the syntax is not nice.
> 
> I think the best clearest way to set @INC would be to use exactly 
> the same logic as Perl(Set|Add)Var use, but handle @INC.
> 
> PerlSetINC
> PerlAddINC
> 
> and have a special table entry in dir and srv configs for @INC.
> 
> what do you think?

Sounds good to me, but I have a question.  If one does :

<Location /foo>
  PerlSetINC /this/dir
</Location>

</Location /bar>
  PerlSetINC /this/other/dir
</Location>

Can I assume that it would:

1.  Populate @INC on a per-request/per-location basis ?
2.  Allow for changes of @INC , like if the application code fiddles
    with it, be guaranteed that whatever is specified by PerlSetINC
    will be in @INC for every request?

In any case, I like the syntax ;-)

+0 on concept.

> _____________________________________________________________________
> Stas Bekman             JAm_pH      --   Just Another mod_perl 
> Hacker
> http://stason.org/      mod_perl Guide   
> http://perl.apache.org/guide
> mailto:stas@stason.org  http://ticketmaster.com 
> http://apacheweek.com
> http://singlesheaven.com http://perl.apache.org 
> http://perlmonth.com/
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
> For additional commands, e-mail: dev-help@perl.apache.org
> 

-- 
+----------------------------------------------------+
| Philippe M. Chiasson  <go...@cpan.org>             |
+----------------------------------------------------+
| F9BF E0C2 480E 7680 1AE5  3631 CB32 A107 88C3 A5A5 |
+----------------------------------------------------+
gethostent not implemented : Your C library apparently
doesn't implement gethostent(), probably because if it did,
it'd feel morally obligated to return every hostname on the
Internet. 
        -- perldiag(1)

perl -e '$$=\${gozer};{$_=unpack(P26,pack(L,$$));/^Just Another Perl Hacker!\n$/&&print||$$++&&redo}'

Re: [patch] PerlINC implementation

Posted by Stas Bekman <st...@stason.org>.
Doug MacEachern wrote:

> On Mon, 12 Nov 2001, Stas Bekman wrote:
> 
> 
>>this patch implements the PerlINC wrapper which does:
>>s/PerlSwitches -Ilib=foo/PerlINC foo/
>>
> 
> if we add a new directive like this i think it should be a wrapper around
> what 'Perl{Set,Pass}Env PERL5LIB' would do, that is:
> 
> - unshift @INC
> - work per-directory
> 
> otherwise, i don't see the value in adding a new directive for something
> that can already be done with PerlSwitches or a 'use lib ...' in a
> PerlRequire'd file.


Now that PerlSetEnv is in place, the only missing thing is
porting from 1.x the special handling of PERL5LIB env var in the 
beginning of request and server startup.

I think this also should be done disregarding the value of SetupEnv, 
since it's a special variable.

Another issue is what happens if someone specifies:

PerlSetEnv Perl5LIB /foo
and
PerlINC /foo

in the same configuration scope. The thing about the two is that you 
cannot repeat the directives ala 'use lib' or PerlSwitches.

So may be we shouldn't endorse using 'PerlSetEnv PERL5LIB', but only 
'PerlPassEnv PERL5LIB'. I prefer to have one convenient way to mangle 
@INC, which satisfies needs of all. So far 'PerlSwitches -Mlib=/foo' is 
  a such, but the syntax is not nice.

I think the best clearest way to set @INC would be to use exactly the 
same logic as Perl(Set|Add)Var use, but handle @INC.

PerlSetINC
PerlAddINC

and have a special table entry in dir and srv configs for @INC.

what do you think?

_____________________________________________________________________
Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
mailto:stas@stason.org  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [patch] PerlINC implementation

Posted by Doug MacEachern <do...@covalent.net>.
On Mon, 12 Nov 2001, Stas Bekman wrote:

> this patch implements the PerlINC wrapper which does:
> s/PerlSwitches -Ilib=foo/PerlINC foo/

if we add a new directive like this i think it should be a wrapper around
what 'Perl{Set,Pass}Env PERL5LIB' would do, that is:

- unshift @INC
- work per-directory

otherwise, i don't see the value in adding a new directive for something
that can already be done with PerlSwitches or a 'use lib ...' in a
PerlRequire'd file.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org