You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Andrew O'Brien <an...@switchonline.com.au> on 2002/02/01 01:27:20 UTC

Re: really basic mod_perl usage

On Thu, Jan 31, 2002 at 02:32:50PM -0500, Joshua Spoerri wrote:
> a really basic mod_perl usage question:
> what's the preferred way for multiple embperl pages to include a single
> instance of data from one file (including apache::dbi handles behind
> dbix objects ) ?
> 
> i'd like to do:
> [-
> Execute({inputfile=>'mycommon.html', package=>'mycommon'});
> $mycommon::myset->Search();
> -]
> and have mycommon.html consist of one large [! !] block
> 
> if i instead do the Execute in startup.pl (which would be even better,
> since it could be shared by all apache children), my pages don't even
> see the package.

You can use

PerlSetEnv EMBPERL_OBJECT_HANDLER_CLASS Some::Module

.. which will cause all $req objects to inherit from this class. This
class must contain HTML::Embperl::Req in his @ISA array

This is good if you just have one unchanging module. If you have
multiple or, like me, you want them to be different for different
parts of the site then:


use the 'object' option to Execute like so:

$lib = Execute({object => 'lib.epl'});

This has several advantages:

1) lib.epl can be overridden in different sections of your site.

   For example, you've got a function that returns a list of
   icons/links to place in a menubar. Very easy to override this
   function whenever you need a change in a different directory like
   so:

/somedir/lib.epl:
[# This makes embperl look through the search path for another
   lib.epl to inherit from. Isn't restricted to be one directory
   back! lib.epl can be found anywhere further in the search path. #]
[! Execute ({isa => '../lib.epl'}) !]

[!
 sub menu_content {
   my $self = shift;
   # add something to the bottom
   return ( $self->SUPER::menu_content(), 'something' );
 }
!]

2) You can stick the $lib object into $req in your base.epl or
   init.epl or whatever like so:

base.epl:
$req = shift;
$req->{libobj} = Execute({object => 'lib.epl'});

somepage.html:
$req = shift;
# call the do_stuff() function in lib.epl
$req->{libobj}->do_stuff( @my_args );

3) You're not limited to just one. Have as many as you like. A
   veritable object party!

Hope this helps.

-- 
 Andrew O'Brien                                                               
 Senior Engineer                         email: andrewo@switchonline.com.au.
 Switch Online Group Pty Limited         phone: +61 2 9299 1133             
 ABN 89 092 286 327                      fax:   +61 2 9299 1134             

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


I cannot get embperl to stop logging

Posted by Hans de Groot <ha...@interspective.nl>.
Hi, 
I have a silly problem, 
Today I noticed that embperl (only on that specific server) keep logging to /tmp/embperl.log , and a lot of data it logs indeed.
I cannot get it to stop and I do not understand why not. 

I set 
SetEnv EMBPERL_DEBUG 0
#PerlSetEnv EMBPERL_DEBUG 0

in my httpd.conf. (I also tried the PerlSetEnv both at the same time and seperate) but it just keeps logging.

Here my $ENV: 

SCRIPT_FILENAME : /home/www/www.hetmooisteplekje.nl/docs/j.html
EMBPERL_OPTIONS : 2064
EMBPERL_DEBUG : 0
PATH : /sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin
SERVER_PORT : 80
EMBPERL_ESCMODE : 0

So it seems debug is set to 0.

Are there any other places where this is set? coz even a plain html files causes embperl to log, and it really slows things down.

help

thx

Hans de Groot


------
Hans de Groot
Interspective Internet Services B.V.
Tel: +31 (0) 30 6001180
Fax +31 (0) 30 6044204
www:   http://www.interspective.nl
email:   hansg@interspective.nl




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