View on
David R. Baird > Maypole-Virtual-Application-0.01 > Maypole::Virtual::Application



Annotate this POD

View/Report Bugs
Module Version: 0.01   Source  


Maypole::Virtual::Application - create multiple Maypole apps on the fly


    package BeerDB;
    use strict;
    use warnings;
    use Class::DBI::Loader::Relationship;
    use Maypole::Virtual::Application; 
    Maypole::Virtual::Application->install_packages( qw( -Debug AutoUntaint ) );
    # beer for everyone!
    sub virtual_packages { map { __PACKAGE__ . "::Site$_" } 1 .. 100 }
    sub initialize_package
        my ( $self, $package ) = @_;
        $package =~ /(Site\d+)$/;
        my $site = $1;
        my $username = My::Config::System->get_beerdb_username_for( $site );
        my $password = My::Config::System->get_beerdb_password_for( $site );
        $package->setup( "dbi:mysql:BeerDB$site", 
        $package->config->{template_root}  = '/home/beerdb/www/www/htdocs';
        $package->config->{uri_base}       = '/';
        $package->config->{rows_per_page}  = 10;
        $package->config->{display_tables}   = [ $package->config->loader->tables ]; 
        $package->config->{application_name} = 'The Beer Database';
        $package->config->loader->relationship( $_ ) for (
            'a brewery produces beers',
            'a style defines beers',
            'a pub has beers on handpumps',
        # this would get called anyway during the first request, but 
        # putting it here is useful under mod_perl to get all initialisation 
        # done before forking off child servers
    sub my_custom_request_method
        # all virtual apps inherit from this package (BeerDB in this case), 
        # so methods defined here are inherited by all Maypole request objects 
        # in the virtual apps.


Use this class to setup multiple applications 'on the fly'. This might be useful in a mod_perl virtual hosting environment, where you want to give each site its own version of a Maypole application.


install_packages( @plugins )

Pass the list of plugins and flags to be installed in each application, just as with Maypole::Application. This method then uses the virtual_packages callback to get a list of package names to install, installs each package using Maypole::Application, and runs the initialize_package callback to configure each package.

Maypole::Application ^

There's a bug in Maypole::Application that needs to be fixed before using this module. You can download a fixed version of Maypole::Application from, until the patch is incorporated in Maypole::Application proper. That version of Maypole::Application also works with MasonX::Maypole (as well as the other Maypole frontends). The build script should check for version 2.10, as does the main package, so you should install the patched Maypole::Application before attempting to install this.


David Baird, <>


Please report any bugs or feature requests to, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.



Copyright 2005 David Baird, All Rights Reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: