You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by wa...@library.ho.lucent.com on 2000/02/16 17:15:54 UTC

SSI and embperl - how to do both

  (Believe this has come up but can't find/figure it - sorry)

We have many pages using perl SSI includes like
     <!--#perl sub="Apache::People" arg="name" arg="Unknown person"-->

We are migrating towards embperl - and the question is, how to migrate
constructs such as the above. 

  What would probably be easiest is to leave them as is.  I thought
stacked handlers was the answer, but SSI is not a handler (am I sounding
confused). So don't believe I can do it with stacked handlers - if can, what
is the SSI handler called?
 
   Other ideas / solutions very welcome. Esp ones minimizing the impact
on the people who write the pages. 

  THanks much,

Bob Waldstein (wald@lucent.com)
MH 3D-591  908 582-6171

Re: SSI and embperl - how to do both

Posted by Ken Williams <ke...@forum.swarthmore.edu>.
Yes, that's the problem.  You can change the line to:

 <!--#perl sub="Apache::Peopledata::handler" arg="name" arg="Unknown person"-->



wald@library.ho.lucent.com (PDS[A]-Robert Waldstein(MT5458)m055) wrote:
>
>> 
>> PerlModule Apache::EmbperlFilter Apache::SSI
>> <FilesMatch "\.epl">
>>    PerlSetVar Filter On
>>    PerlHandler Apache::EmbperlFilter Apache::SSI
>> </FilesMatch>
>
>Okay - I give. I think I may be hitting a bug in Apache::SSI, or something.
>I turned of Filter and removed the chained handlers so had just
>	PerlHandler  Apache::SSI
>
>and still the line in my file that looks like
>   <!--#perl sub="Apache::Peopledata" arg="name" arg="Unknown person"-->
>
>fails and give the following error (I turned on Debug in SSI):
>
>returning $self->ssi_perl(sub="Apache::Peopledata" arg="name" arg="Unknown person") 
>at /opt1/perl/lib/site_perl/Apache/SSI.pm line 117.
>args are sub,Apache::Peopledata,arg,name,arg,Unknown person at 
>/opt1/perl/lib/site_perl/Apache/SSI.pm line 119.
>sub is Apache::Peopledata, args are name Unknown person &  at 
>/opt1/perl/lib/site_perl/Apache/SSI.pm line 287.
>sub is CODE(0x55d75c), args are Apache=SCALAR(0x1d3c20) name Unknown person &  at 
>/opt1/perl/lib/site_perl/Apache/SSI.pm line 303.
>[Fri Feb 18 16:40:57 2000] [error] Undefined subroutine &Apache::Peopledata called 
>at /opt1/perl/lib/site_perl/Apache/SSI.pm line 304.
> 
>
>Same construct works under mod_include.  THe Peopledata.pm has a 
>   sub handler {
>
>which is not exported or anything - is that my problem??
>
>  Help?  THanks much,
>    Bob Waldstein  wald@lucent.com
>

  -------------------                            -------------------
  Ken Williams                             Last Bastion of Euclidity
  ken@forum.swarthmore.edu                            The Math Forum



Re: SSI and embperl - how to do both

Posted by "PDS[A]-Robert Waldstein(MT5458)m055" <wa...@library.ho.lucent.com>.
> 
> PerlModule Apache::EmbperlFilter Apache::SSI
> <FilesMatch "\.epl">
>    PerlSetVar Filter On
>    PerlHandler Apache::EmbperlFilter Apache::SSI
> </FilesMatch>

Okay - I give. I think I may be hitting a bug in Apache::SSI, or something.
I turned of Filter and removed the chained handlers so had just
	PerlHandler  Apache::SSI

and still the line in my file that looks like
   <!--#perl sub="Apache::Peopledata" arg="name" arg="Unknown person"-->

fails and give the following error (I turned on Debug in SSI):

returning $self->ssi_perl(sub="Apache::Peopledata" arg="name" arg="Unknown person") at /opt1/perl/lib/site_perl/Apache/SSI.pm line 117.
args are sub,Apache::Peopledata,arg,name,arg,Unknown person at /opt1/perl/lib/site_perl/Apache/SSI.pm line 119.
sub is Apache::Peopledata, args are name Unknown person &  at /opt1/perl/lib/site_perl/Apache/SSI.pm line 287.
sub is CODE(0x55d75c), args are Apache=SCALAR(0x1d3c20) name Unknown person &  at /opt1/perl/lib/site_perl/Apache/SSI.pm line 303.
[Fri Feb 18 16:40:57 2000] [error] Undefined subroutine &Apache::Peopledata called at /opt1/perl/lib/site_perl/Apache/SSI.pm line 304.
 

Same construct works under mod_include.  THe Peopledata.pm has a 
   sub handler {

which is not exported or anything - is that my problem??

  Help?  THanks much,
    Bob Waldstein  wald@lucent.com

Re: SSI and embperl - how to do both

Posted by Ken Williams <ke...@forum.swarthmore.edu>.
wald@library.ho.lucent.com (PDS[A]-Robert Waldstein(MT5458)m055) wrote:
>
>Thanks Michael - this looks very much like what I needed.  As I set this up
>it raises a question:
>  why not use the Apache::SSI for the SSI files (*.shtml) instead of the 
>  mod_include module? And remove that module totally from the Apache build?
>
>Any down side to this (beyond that it failed the ssi "make test").

Yeah, mod_include is quite a bit faster.  I haven't benchmarked anything, but a
couple people have told me they've seen a difference.  

Of course, Apache::SSI is a bit more forgiving with syntax and more friendly
when you make errors, and a LOT more flexible and extendible.  If all you need
is mod_include though, that's probably what you should use.

Obviously I like Apache::SSI, since I wrote it, but I must confess I don't
actually use it very much.  Kind of a hobby module. =)  But for lots of people
it's just the ticket when they need to tweak the way SSI works, or chain
filters, or whatever.


  -------------------                            -------------------
  Ken Williams                             Last Bastion of Euclidity
  ken@forum.swarthmore.edu                            The Math Forum



Re: SSI and embperl - how to do both

Posted by "PDS[A]-Robert Waldstein(MT5458)m055" <wa...@library.ho.lucent.com>.
> 
> Here is my handler that solves it:
> 
> use it in a FilesMatch or whatever you want...
> 
> PerlModule Apache::EmbperlFilter Apache::SSI
> <FilesMatch "\.epl">
>    PerlSetVar Filter On
>    PerlHandler Apache::EmbperlFilter Apache::SSI
> </FilesMatch>

Thanks Michael - this looks very much like what I needed.  As I set this up
it raises a question:
  why not use the Apache::SSI for the SSI files (*.shtml) instead of the 
  mod_include module? And remove that module totally from the Apache build?

Any down side to this (beyond that it failed the ssi "make test").

 thanks, Bob Waldstein  wald@lucent.com

Re: SSI and embperl - how to do both

Posted by Michael schout <ms...@gkg.net>.
wald@library.ho.lucent.com wrote:
> 
>   (Believe this has come up but can't find/figure it - sorry)

Here is my handler that solves it:

use it in a FilesMatch or whatever you want...

PerlModule Apache::EmbperlFilter Apache::SSI
<FilesMatch "\.epl">
   PerlSetVar Filter On
   PerlHandler Apache::EmbperlFilter Apache::SSI
</FilesMatch>

package Apache::EmbperlFilter;

use Apache::Util qw(parsedate);
use HTML::Embperl;
use Apache::SSI ();
use Apache::Constants;

use strict;
use vars qw($VERSION);

$VERSION = '0.03';
my ($r, %param, $input, $output);

sub handler {
    $r = shift;
    my ($fh, $status) = $r->filter_input();
    unless ($status == OK) {
        return $status
    }
    local $/ = undef;
    $input = scalar(<$fh>);
    %param = ();
    $param{input} = \$input;
    $param{req_rec} = $r;
    $param{output} = \$output;
    $param{mtime} = mtime();
    $param{inputfile} = $r->filename();
    HTML::Embperl::ScanEnvironement(\%param);
    HTML::Embperl::Execute(\%param);
    print $output;
    return OK;
}

sub mtime {
    my $mtime = undef;
    if (my $last_modified = $r->headers_out->{'Last-Modified'}) {
        $mtime = parsedate $last_modified;
    }
    $mtime;
}

1;

__END__