[prev in list] [next in list] [prev in thread] [next in thread]
List: mason
Subject: [Mason] Mason in Home Directories
From: John Keiser <jkeiser () iname ! com>
Date: 2001-07-23 21:31:58
[Download RAW message or body]
I had a problem a while back where I wanted individuals on my machine
(who each have their own /~<user> dir) to each have their own component
roots that didn't interfere with each other. The way I solved it was to
make a handler.pl that instantiated a separate interpreter and handler
for each home directory with its own component root.
My handler() looks like this:
sub handler
{
my ($r) = @_;
# If you plan to intermix images in the same directory as
# components, activate the following to prevent Mason from
# evaluating image files as components.
#
return -1 if $r->content_type && $r->content_type !~ m|^text/|i;
#
# Have a different handler for each home directory
#
my $curr_ah;
my $filename = $r->filename();
if($filename =~ m!/home/([^/]*)/public_html!) {
my $user_name = $1;
$curr_ah = $user_handlers{$user_name};
if(!$curr_ah) {
my $user_dir = "/home/$1/public_html";
my $parser = new HTML::Mason::Parser(allow_globals => [
qw($dbh) ]);
my $interp = new HTML::Mason::Interp(parser=>$parser,
comp_root=>[[$user_name
=> $user_dir]],
data_dir=>"/var/www/mason");
$curr_ah = new HTML::Mason::ApacheHandler(interp=>$interp);
$user_handlers{$1} = $curr_ah;
}
} else {
$curr_ah = $base_ah;
}
my $status = $curr_ah->handle_request($r);
return $status;
}
Is there a better way to do this? I just realized when I submitted a
HOWTO that I might be doing it bass-ackwards :)
--John Keiser
_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/mason-users
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic