Aighearach has asked for the wisdom of the Perl Monks concerning the following question:

I have been placed in the uncomfortable position of doing web design, on a site I'm only supposed to be programming for. Because I don't want to maintain any of the data more than once, I am using ssi to source in the files for the different screen areas. (ads, menus, etc) This is an Apache web server on linux, of course. I'd write it all in Perl, but then I would be stuck maintaining it! No, I want to hand it off as soon as we find an HTML person, and I don't want to require that they know Perl. So here is my problem:

How do I use my ssi template file, and insert the response to a submitted form in it? I don't want to use cookies; I took an Oath not to use them. What I really wish I could do, and maybe there is a way, is to force the apache server to take a pass at what my Perl program produces, so that I can just use an ssi in the script output to parse in the shtml. I know this is not possible in normal CGI, but since I am doing everything in mod_perl, perhaps there is a way to set up the handlers to do this? I could also read the template file in by hand, but this is not efficient. I could open a connection to the web server, and ask for the template shtml, but that also does not seem efficient.

Any Monks know the best way to do this?

Replies are listed 'Best First'.
Re: mod_perl and ssi: mixing it up
by btrott (Parson) on May 22, 2000 at 23:57 UTC
    (Actually, it's mod_include, not mod_ssi. I think.)

    To the OP: take a look at Apache::SSI.

    Also read about output chaining--as mdillon said, you should be able to set up your config so that output from your program goes through mod_include.

      mod_include... that's what i meant. thanks.

      also, although i've heard about this "output chaining" on mailing lists, i could not find any documentation on it just now to enhance my previous post with. am i correct that this is an Apache-2.0-only feature?

        I don't think so. I'm pretty sure it's possible, using mod_perl, in versions less than 2.0. Although you may be right that the support for *module* chaining (as opposed to stacked Perl handlers) comes with 2.0.

        There's a module called Apache::OutputChain, and there's another called Apache::Filter. Both do sort of the same thing: they let you chain together several modules, with each successive module being able to write to/affect STDOUT.

        The OP should probably take a look at these modules. In particular, Apache::Filter might work for him, in combination with Apache::SSI. Something like this in httpd.conf:

        PerlModule Apache::Filter; <Files /foo> SetHandler perl-script PerlSetVar Filter On PerlHandler YourModule Apache::SSI </Files>
        In YourModule, just print to STDOUT (or $r->print, I suppose). This output will be filtered through Apache::SSI, which (I believe) should fill in the includes.

        Mind you, I've never done this myself.

Re: mod_perl and ssi: mixing it up
by mdillon (Priest) on May 22, 2000 at 23:53 UTC
    i have not tried this myself yet, but i think that Apache 2.0 supports module chaining, so that the output of mod_perl could be passed through mod_ssi.
RE: mod_perl and ssi: mixing it up
by Aighearach (Initiate) on May 24, 2000 at 05:12 UTC
    Of course all I had to do was spend half an hour giving all the code, and configs, and submit it before I found something that would work. :) heh heh
    THANKS very much!

    The configuration that finally worked was:

    Alias /foo /home/httpd/foo <Location /foo> SetHandler "perl-script" Options +ExecCGI PerlHandler Apache::OutputChain Apache::SSIChain Apache::Registry </Location>
    But it only works if it isn't covered by another rule; /perl/foo doesn't work. That is what was giving me most of my troubles, I had good config directives, but it was matching something else first. mod_perl kicks as, it's fast, it's stable, it's humbling.
    Paris Sinclair    |    4a75737420416e6f74686572
    pariss@efn.org    |    205065726c204861636b6572
    I wear my Geek Code on my finger.
    
      <--snip-->
      The configuration that finally worked was:
      Alias /foo /home/httpd/foo <Location /foo> SetHandler "perl-script" Options +ExecCGI PerlHandler Apache::OutputChain Apache::SSIChain Apache::Registr +y </Location>
      <--snip-->

      This looks like exactly what i need, but I can't find it doc'd anywhere...I've been pouring through apache.org and apache journal with no luck. does anyone have a url on this?

      -- I'm a solipsist, and so is everyone else. (think about it)