A very efficient and flexible mod_perl-based dynamic web generation system, one of the best systems all-over in my opinion (main problem : it's very difficult to understand what you wrote six months ago...) -- LaurentDaverio
Wrapping UseModWiki within Mason
This is very old code for me (I switched to Python and Zope around 2000-2001), but fortunately I've kept archives :-)
What I would have liked to do (should have worked, but didn't - I was probably very close to the solution):
Basically, It would redirect UseModWiki's output to a temp file ('select' statement), and then copy this temp file to Mason's output ($m->out). I'm aware that it may not have been the most scalable/efficient/clean solution, but I was more interested in integrating the wiki within my site's layout (it's probably possible to use a tempfile in RAM instead of on-disk to speed things up).
<%perl>
use File::Temp qw/tempfile/;
my ($fh, $fn) = tempfile (DIR => '/tmp');
select $fh;
{ require "/projects/Trad/cgi-bin/wiki" || die $!; }
select STDOUT;
open IN, "$fn" || die $!;
while (my $in = <IN>) { $m->out($in) }
close IN;
unlink $fn;
</%perl>
Unfortunately, I never managed to get the "require" to work, so I resorted to copying UseModWiki's code inside my wrapper (given the long timespan between UseModWiki releases, this may not be as big a problem as I thought at the time):
<perl>
use File::Temp qw/tempfile/;
my ($fh, $fn) = tempfile (DIR => '/tmp');
select $fh;
{
############################################################
#!/usr/local/bin/perl
# UseModWiki version 0.92 (April 21, 2001)
# Copyright (C) 2000-2001 Clifford A. Adams
[snip]
&DoWikiRequest() if ($RunCGI && ($_ ne 'nocgi')); # Do everything.
1; # In case we are loaded from elsewhere
# == End of UseModWiki script. ===========================================
############################################################
}
select STDOUT;
open IN, "$fn" || die;
while (my $in = <IN>) { $m->out($in) }
close IN;
unlink $fn;
</%perl>
I'm fairly confident that this should work with any version of Mason and UseModWiki, as the latter has an extremely clean code, which allows it to be used as a package inside a main Perl script, without suffering from side effects such as overwriting global variables.