MP2 Script within another script AND via SSI

2006-07-11 Thread cfaust-dougot
Morning All,
 
What I have below works, but for some reason I'm 
not all that comfortable with it.. Could someone tell me if I'm doing anything 
evil with my approach??
 
MP2 (ParseNav.pm) Script Description:
Needed a script to create page navigation, the nav 
needs to be called within other MP2 scripts as well as in standard static pages 
(via ssi)
 
When I want the nav within another MP2 script, I 
simply...
 
 my $top_nav = SCRIPTS::ParseNav->cgi_nav($r);
 
When I want the nav in a static HTML page, I simply..
 

 
Below is the basic ParseNav script - TIA for any help or advise..
-Chris
 
package 
SCRIPTS::ParseNav;
use strict;use vars qw($r);
## Set some Constants# Template Path$ENV{'HTML_TEMPLATE_ROOT'} = 
xxx";# Our Content Templatemy $content = "Navigation.tmpl";
### 
Main# Our Mod_Perl Content Handlersub handler { $r = shift;
 &cgi_nav();
 # As this is being called from a include, set a header and print it 
out $r->send_http_header; print 
$content->output;   # Return our header as we are 
done!!! return Apache::OK; } # End of 
Sub##sub 
cgi_nav { my ($self,$r) = @_;
# do what we want to do and return the content template to the requesting MP2 
script
return $content;
}
 
 
 
 
 
 
 
 

Re: MP2 Script within another script AND via SSI

2006-07-11 Thread Perrin Harkins
On Tue, 2006-07-11 at 09:50 -0400, cfaust-dougot wrote:

> What I have below works, but for some reason I'm not all that
comfortable with
> it.. Could someone tell me if I'm doing anything evil with my
approach??

Looks fine to me.  SSI virtual includes are quite efficient with
mod_perl.

- Perrin



RE: MP2 Script within another script AND via SSI

2006-07-11 Thread cfaust-dougot
Title: Re: MP2 Script within another script AND via SSI






Thanks Perrin, don't know why 
it was bothering me soo much, but I feel better now!!


From: Perrin Harkins 
[mailto:[EMAIL PROTECTED]Sent: Tue 7/11/2006 11:03 AMTo: 
cfaust-dougotCc: modperl@perl.apache.orgSubject: Re: MP2 
Script within another script AND via SSI

On Tue, 2006-07-11 at 09:50 -0400, cfaust-dougot 
wrote:> What I have below works, but for some reason I'm not all 
thatcomfortable with> it.. Could someone tell me if I'm doing 
anything evil with myapproach??Looks fine to me.  SSI virtual 
includes are quite efficient withmod_perl.- 
Perrin




Re: MP2 Script within another script AND via SSI

2006-07-11 Thread Michael Peters


Perrin Harkins wrote:
> On Tue, 2006-07-11 at 09:50 -0400, cfaust-dougot wrote:
> 
>> What I have below works, but for some reason I'm not all that
> comfortable with
>> it.. Could someone tell me if I'm doing anything evil with my
> approach??
> 
> Looks fine to me.  SSI virtual includes are quite efficient with
> mod_perl.

They are efficient, but you still need to be careful. At ApacheCon::EU they
mentioned changing all apache.org sites to include a banner ad for the next
ApacheCon that would rotate and they used SSI to do it. It increased their
traffic 2-3x because it broke all of the caching happening at browsers, routers
and proxies.

If the content is truly dynamic, then it's a good solution. If it's content that
rarely changes, pre-generation is probably a better solution.

-- 
Michael Peters
Developer
Plus Three, LP



Re: MP2 Script within another script AND via SSI

2006-07-11 Thread Jonathan Vanasco

On Jul 11, 2006, at 9:50 AM, cfaust-dougot wrote:

pa 
ckage SCRIPTS::ParseNav;

use strict;
use vars qw($r);

## Set some Constants
# Template Path
$ENV{'HTML_TEMPLATE_ROOT'} = xxx";
Perhaps an issue of style, but would that not be better set in  
httpd.conf ?

# Our Content Template
my $content = "Navigation.tmpl";

##
# Main
# Our Mod_Perl Content Handler
sub handler {
 $r = shift;

 &cgi_nav();

you're not passing $r here into cgi_nav
 # As this is being called from a include, set a header and print  
it out

 $r->send_http_header;
 print $content->output;

 # Return our header as we are done!!!
 return Apache::OK;

} # End of Sub


another personal thing...  i'd wrap the cgi_nav -> print in an eval  
block.  you'd probably want to return Apache::OK in any event, but if  
you get some crazy error, why die?