I’ve started playing a little bit with Maypole, described ambitiously (not to mention ambiguously, and ambivalently) as “Struts for Perl”. I’ve run into some trouble getting it working (multiple trips to the debugger), partially because its still under heavy development (and most of this info will be irrelevant by the time you read it), partially because it heavily leverages the hard core, write no code, magical end of CPAN, and partially because I’m installing it onto a totally vanilla system, and that means I have to install a lot of modules. (not a criticism)

I’m trying to get Maypole, running under mod_perl (its native environment, though there is also a CGI::Maypole in early stages), and get the sample app, BeerDB running. Basic documentation (which took me a little while to track down) is in the POD for Apache::MVC, and on the BeerDB page (which also contains the database schema)

Besides cpan> install Maypole you’ll also need to create the database and tables, edit BeerDB.pm with proper URL, and database connect info (mine looks like BeerDB->setup("dbi:mysql:beerdb", $user, $pass);), and copy the factory, and custom template directories to the proper location under your docroot.

Errors

Some errors I ran into and their solutions.

  • This is an abstract method at Maypole/Model/Base.pm line 108.

    This means Maypole::Model::CDBI is failing to be instantiated, but the error is being suppressed by UNIVERSAL::require (fixed in 1.3). In my case I needed to install Class::DBI::AsForm.

  • Can't locate object method "set_db" via package "BeerDB::Beer" at Class/DBI/Loader/mysql.pm

    A documented problem, which I unfortunately didn’t find in time. Means Class::DBI::Loader needs you to install Class::DBI::mysql.

  • All the code seems to be working, but no HTML is displayed.

    First make sure you’re going to an explicit action (like /beerdb/brewery/list), I don’t know if there are supposed to be default behaviours, but they aren’t working for me. If you are requesting an explicit action, check the factory/header template (and replace the second <TITLE> tag with a </title> tag)

  • plugin error - Class: plugin not found at Maypole/View/TT.pm line 73.

    Install Template::Plugin::Class

Tip

You can quickly improve the look of the default templates by copying flox.css to “beerdb.css”, and editing your header template to use it. ### Some Data

Here is some data to jump start you (I assumed the handpump table is used to represent beers a pub has on tap) > insert into brewery (name,url) values (‘Elysian Brewing Company’, ‘http://www.elysianbrewing.com/’); insert into pub (name,url,notes) values (‘Tangletown’,”,’2106 N 55th St’); insert into style (name) values (‘IPA’); insert into style (name) values (‘Pilsner’); insert into beer (name, brewery, style) values (‘Elysian Fields’, 1, 1); insert into beer (name, brewery, style) values (‘Zephyrus’, 1, 2); insert into handpump (beer,pub) values (1,1); insert into handpump (beer,pub) values (2,1)

How is the actual framework? I don’t know yet, but I feel like I’m getting closer to finding out.