The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

MasonX::Maypole - use Mason as the frontend and view for Maypole version 2

VERSION

Version 0.02

SYNOPSIS

    package BeerDB;
    use warnings;
    use strict;

    use Class::DBI::Loader::Relationship;

    use MasonX::Maypole 0.2;
    use base 'MasonX::Maypole';

    BeerDB->setup( 'dbi:mysql:beerdb' );

    BeerDB->config->{view}           = 'MasonX::Maypole::View';
    BeerDB->config->{template_root}  = '/var/www/beerdb';
    BeerDB->config->{uri_base}       = '/beerdb';
    BeerDB->config->{rows_per_page}  = 10;
    BeerDB->config->{display_tables} = [ qw( beer brewery pub style ) ];

    BeerDB->config->masonx->{comp_root}  = [ factory => '/var/www/maypole/factory' ];
    BeerDB->config->masonx->{data_dir}   = '/path/to/mason/data_dir';
    BeerDB->config->masonx->{in_package} = 'My::Mason::App';

    BeerDB::Brewery->untaint_columns( printable => [qw/name notes url/] );

    BeerDB::Style->untaint_columns( printable => [qw/name notes/] );

    BeerDB::Beer->untaint_columns(
        printable => [qw/abv name price notes/],
        integer => [qw/style brewery score/],
        date => [ qw/date/],
    );

    BeerDB->config->{loader}->relationship($_) for (
        "a brewery produces beers",
        "a style defines beers",
        "a pub has beers on handpumps");

    1;

DEVELOPER RELEASE

This release is fundamentally different from previous MasonX::Maypole releases, and will break sites that are using them. Previous releases did not work with Maypole 2. This and future releases will not work with Maypole 1.

DESCRIPTION

A frontend and view for Maypole 2, using Mason.

CONFIGURING MASON

Set any parameters for the Mason ApacheHandler in My::Maypole::App-config->{masonx}>. This is where to tell Maypole/Mason where the factory templates are stored.

TEMPLATES

This distribution includes Masonized versions of the standard Maypole templates, plus a dhandler and autohandler. The autohandler simply takes care of adding a header and footer to every page.

The dhandler is responsible for implementing part of the Maypole template lookup behaviour. It first looks for a template specific to the table being queried by the request. If no such template is found, it defers the lookup to Mason's component search path. This is set in init. The result is that the lookup follows the same sequence as described in the Maypole documentation (table > site > factory). You can add extra component roots if you need them.

So if you set the factory comp_root to point at the Maypole factory templates, the thing should Just Work right out of the box.

METHODS

init

This method is called by Maypole during startup. Sets up the Mason ApacheHandler.

parse_args

Uses Mason to extract the request arguments from the request.

send_output

Template variables have already been exported to Mason components namespace in MasonX::Maypole::View::template. This method now runs the Mason Cexec> phase to generate and send output.

AUTHOR

David Baird, <cpan@riverside-cms.co.uk>

TODO

Currently hard-coded to use Apache/mod_perl. Shouldn't be too hard to use CGI instead.

BUGS

Please report any bugs or feature requests to bug-masonx-maypole2@rt.cpan.org, or through the web interface at http://rt.cpan.org. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

TESTS

There are none. The module loads Mason::ApacheHandler, which causes compile time errors unless loaded within mod_perl.

ACKNOWLEDGEMENTS

COPYRIGHT & LICENSE

Copyright 2004 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.