Hi,

I am trying a new way of managing mason virtual hosts with multiple
comp_root's. Here is a summary of my handler.pl script:


        #!/usr/bin/perl
        package HTML::Mason;
        use strict;
        use warnings;
        use HTML::Mason::ApacheHandler;

        {
                package HTML::Mason::Commands;
                ## use many modules
                use vars qw(%session $dbc);
        }

        my %ah_args = (
                        autohandler_name=>'ah.mc',
                        dhandler_name=>'dh.mc',
                        error_mode=>'fatal',
                        args_method=>'mod_perl',
                        );
        my %ah;

        sub handler {

                my ($r) = @_;

                ## database init and session setup stuff deleted

                $ah{$r->document_root} ||= new HTML::Mason::ApacheHandler(
                        %ah_args,
                        comp_root=>$r->document_root,
                        data_dir=>'/tmp/mason/'.$r->get_server_name,
                );
                my $m = $ah{$r->document_root()}->prepare_request($r);

                my $status = ref($m) ? $m->exec : $m;

                return $status;
        }

Basically it turns each mason virtual host's DocumentRoot into its own
comp_root. That way I can install mason sites anywhere in the filesystem
hierarchy without touching mason's configuration. When I need to share
components between sites I pull a 'share/' directory with svn.

Only mason sites will trigger that handler because my mason pages use a
special .md extension:

        AddType text/html .md
        AddHandler perl-script .md
        DirectoryIndex index.md
        <Files *.md>
        PerlHandler HTML::Mason
        </Files>

Is there any gotcha with using that system?

Thanks,

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to