You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Kee Hinckley <na...@somewhere.com> on 2002/08/15 22:12:06 UTC

use lib in EmbperlObject

Is there any way to put a "use lib" command in a called routine (e.g. 
[- Execute({ isa => 'SiteInit.html' }); -]) and have it impact later 
"use" commands?  Any other suggestions.  I hate having to put it in 
every single file.  (Right up there with [$ var $this $][- $this = 
shift -] at the beginning of each file.
-- 

Kee Hinckley - Somewhere.Com, LLC
http://consulting.somewhere.com/

I'm not sure which upsets me more: that people are so unwilling to accept
responsibility for their own actions, or that they are so eager to regulate
everyone else's.

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


Re: use lib in EmbperlObject

Posted by Gerald Richter <ri...@ecos.de>.
> >> On a related topic.  If I do a "use somelibrary" in a template, and
> >> it imports some functions into the name space, it would be nice to be
> >> able to use them in the files that are using that template.
> >
> > Because of the different namespaces of those files this won't work,
sorry.
>
> Isn't this what EMBPERL_PACKAGE is for, so we can do this?

With this you can force them to be in the same namespace, but this leads to
other problems like more memory usage.

> Alternatively, what would be the effect of having the
> EMBPERL_OBJECT_HANDLER_CLASS package do all the 'use' commands (oh,
> wait, that's not in a template.)
>

You may use the EMBPERL_OBJECT_HANDLER_CLASS and make a smal wrapper around
the functions you need and then call them via
[-
$r = shift ;
$r -> myfunc() ;
-]

or you directly implement them in the class you set with
EMBPERL_OBJECT_HANDLER_CLASS.

Gerald

-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------



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


Re: use lib in EmbperlObject

Posted by Ed Grimm <ed...@asgard.rsc.raytheon.com>.
On Thu, 22 Aug 2002, Gerald Richter wrote:

>> On a related topic.  If I do a "use somelibrary" in a template, and
>> it imports some functions into the name space, it would be nice to be
>> able to use them in the files that are using that template.
>
> Because of the different namespaces of those files this won't work, sorry.

Isn't this what EMBPERL_PACKAGE is for, so we can do this?
Alternatively, what would be the effect of having the
EMBPERL_OBJECT_HANDLER_CLASS package do all the 'use' commands (oh,
wait, that's not in a template.)

Ed


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


Re: use lib in EmbperlObject

Posted by Gerald Richter <ri...@ecos.de>.
>
> Here's what I have:
>
> SiteInit.html
> [! use lib "/usr/local/PureMessaging/lib"; !]
> Template.html
> [- Execute({ isa => 'SiteInit.html' }); -]
> Template.html: [+ join(", ", @INC) +]<br>
> [- Execute('*') -]
> index.html
> index.html: [+ join(", ", @INC) +]<br>
>
> Running that the first time gives me:
> Template.html: /usr/local/PureMessaging/lib, /sw/lib/perl5/darwin,
>
> The second time gives me:
> Template.html: /sw/lib/perl5/darwin, /sw/lib/perl5,
>
> And if instead of just printing @INC, I try using something that is
> at that location, it never works.  First time or any other.
>

The first time it should work, because the @INC path is correct.

I remeber something that maybe mod_perl is reseting the @INC array after the
request. That would explain why the path has gone on the second request.

> Moving the use lib to Template.html doesn't help.  Nor does moving it
> and changing it to [-.

The Execute ({isa => }) is always only executed on the first run and [- -]
blocks in it get's never executed, unless they are inside a sub and the sub
is called.

> It has to be in the same file as the "use
> mylibrary" statement.
>

Assuming that mod_perl reseting the @INC, you either have to do it in a file
that really get's executed on every request or put it in the startup.pl
file.

>
> On a related topic.  If I do a "use somelibrary" in a template, and
> it imports some functions into the name space, it would be nice to be
> able to use them in the files that are using that template.

Because of the different namespaces of those files this won't work, sorry.

Gerald


-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------



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


Re: use lib in EmbperlObject

Posted by Kee Hinckley <na...@somewhere.com>.
At 7:25 AM +0200 8/16/02, Gerald Richter wrote:
>  > >>  Is there any way to put a "use lib" command in a called routine (e.g.
>>  >>  [- Execute({ isa => 'SiteInit.html' }); -]) and have it impact later
>>  >>  "use" commands?
>
>use lib is global, because it affects the global @ISA, so it doesn't matter
>where you put it, it will affect all use statements that are executed after
>the use lib.

Here's what I have:

SiteInit.html
	[! use lib "/usr/local/PureMessaging/lib"; !]
Template.html
	[- Execute({ isa => 'SiteInit.html' }); -]
	Template.html: [+ join(", ", @INC) +]<br>
	[- Execute('*') -]
index.html
	index.html: [+ join(", ", @INC) +]<br>

Running that the first time gives me:
Template.html: /usr/local/PureMessaging/lib, /sw/lib/perl5/darwin, 
/sw/lib/perl5, /System/Library/Perl/darwin, /System/Library/Perl, 
/Library/Perl/darwin, /Library/Perl, /Network/Library/Perl/darwin, 
/Network/Library/Perl, ., /usr/local/apache/, 
/usr/local/apache/lib/perl
index.html: /usr/local/PureMessaging/lib, /sw/lib/perl5/darwin, 
/sw/lib/perl5, /System/Library/Perl/darwin, /System/Library/Perl, 
/Library/Perl/darwin, /Library/Perl, /Network/Library/Perl/darwin, 
/Network/Library/Perl, ., /usr/local/apache/, 
/usr/local/apache/lib/perl

The second time gives me:
Template.html: /sw/lib/perl5/darwin, /sw/lib/perl5, 
/System/Library/Perl/darwin, /System/Library/Perl, 
/Library/Perl/darwin, /Library/Perl, /Library/Perl, 
/Network/Library/Perl/darwin, /Network/Library/Perl, 
/Network/Library/Perl, ., /usr/local/apache/, 
/usr/local/apache/lib/perl
index.html: /sw/lib/perl5/darwin, /sw/lib/perl5, 
/System/Library/Perl/darwin, /System/Library/Perl, 
/Library/Perl/darwin, /Library/Perl, /Library/Perl, 
/Network/Library/Perl/darwin, /Network/Library/Perl, 
/Network/Library/Perl, ., /usr/local/apache/, 
/usr/local/apache/lib/perl

And if instead of just printing @INC, I try using something that is 
at that location, it never works.  First time or any other.

Moving the use lib to Template.html doesn't help.  Nor does moving it 
and changing it to [-.  It has to be in the same file as the "use 
mylibrary" statement.


On a related topic.  If I do a "use somelibrary" in a template, and 
it imports some functions into the name space, it would be nice to be 
able to use them in the files that are using that template.
-- 

Kee Hinckley - Somewhere.Com, LLC
http://consulting.somewhere.com/

I'm not sure which upsets me more: that people are so unwilling to accept
responsibility for their own actions, or that they are so eager to regulate
everyone else's.

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


Re: use lib in EmbperlObject

Posted by Gerald Richter <ri...@ecos.de>.
> >>  Is there any way to put a "use lib" command in a called routine (e.g.
> >>  [- Execute({ isa => 'SiteInit.html' }); -]) and have it impact later
> >>  "use" commands?

use lib is global, because it affects the global @ISA, so it doesn't matter
where you put it, it will affect all use statements that are executed after
the use lib.

>>>Any other suggestions.  I hate having to put it in
> >>  every single file.  (Right up there with [$ var $this $][- $this =
> >>  shift -] at the beginning of each file.

These $this = shift was introduced to be able to support the old thread
model, like Perl 5.005 has it. Since this thread model never had worked
anyway in Perl and now with 5.8.0 we have a new thread model, it should be
possible to make what you call $this a global like %fdat. I will think about
this...

> >
> >Is there a reason you don't just want to load all your 'use lib's up
> >in your startup.pl?
>
> Per-site libraries on a virtual server?  And some of the libraries
> aren't used that often (e.g. the administration section of a web
> site).

use lib is global anyway, so you can put it in the startup.pl. It will not
take up any additional memory, just add a path to @ISA

Gerald


-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------



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


Re: use lib in EmbperlObject

Posted by Kee Hinckley <na...@somewhere.com>.
At 8:55 AM +1000 8/16/02, Gavin Carr wrote:
>On Thu, Aug 15, 2002 at 04:12:06PM -0400, Kee Hinckley wrote:
>>  Is there any way to put a "use lib" command in a called routine (e.g.
>>  [- Execute({ isa => 'SiteInit.html' }); -]) and have it impact later
>>  "use" commands?  Any other suggestions.  I hate having to put it in
>>  every single file.  (Right up there with [$ var $this $][- $this =
>>  shift -] at the beginning of each file.
>
>Is there a reason you don't just want to load all your 'use lib's up
>in your startup.pl?

Per-site libraries on a virtual server?  And some of the libraries 
aren't used that often (e.g. the administration section of a web 
site).
-- 

Kee Hinckley - Somewhere.Com, LLC
http://consulting.somewhere.com/

I'm not sure which upsets me more: that people are so unwilling to accept
responsibility for their own actions, or that they are so eager to regulate
everyone else's.

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


Re: use lib in EmbperlObject

Posted by Gavin Carr <ga...@openfusion.com.au>.
On Thu, Aug 15, 2002 at 04:12:06PM -0400, Kee Hinckley wrote:
> Is there any way to put a "use lib" command in a called routine (e.g. 
> [- Execute({ isa => 'SiteInit.html' }); -]) and have it impact later 
> "use" commands?  Any other suggestions.  I hate having to put it in 
> every single file.  (Right up there with [$ var $this $][- $this = 
> shift -] at the beginning of each file.

Is there a reason you don't just want to load all your 'use lib's up 
in your startup.pl?

-G

-- 
Open Fusion P/L - Open Source Business Solutions [ Linux - Perl - Apache ]
http://www.openfusion.com.au
- Fashion is a variable, but style is a constant - Programming Perl

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