hossman has asked for the wisdom of the Perl Monks concerning the following question:

Ok, so I've got Maypole up and running, and the default factory templates seem to be working great for listing/searching/viewing/editing any item from any of my tables (the main two being "authors" and "pubs"). Next I tried introducing relationships, using Class::DBI::Loader::Relationship...

IsfdbMaypole->config->{loader}->relationship($_) for ( "an author has a note", "a pub has a note", );

...the relationships seem to be generating fine, the ./authors/view and ./pubs/view pages work perfectly, and the value in the note row (if there is one) links to the corrisponding ./notes/view page. Sweet.

The problem I'm having is with the ./authors/list and ./pubs/list (and ./authors/search and ./pubs/search) pages. if the "an author has a note" relationship is defined, then ./authors/list and ./authors/search both generate the following error message in my logs...

plugin error - Class: plugin not found at /home/hossman/.perllib/lib/p +erl5/site_perl/5.8.5/Maypole.pm line 123

...and the page renders as....

Template not found

This template was not found while processing the following request: list on table authors with objects:

...list of authors it wants to display...

Looking for template list in paths:

/home/hossman/public_html/isfdb-maypole/
/home/hossman/public_html/isfdb-maypole/authors
/home/hossman/public_html/isfdb-maypole/custom
/home/hossman/public_html/isfdb-maypole/factory

If I comment the relaionship out, the list page works perfectly again. The exact same thing happens with ./pubs/list and "a pub has a note"

I'm not very familiar with Template::Toolkit, but I suspect the "Template not found" is just a red herring message that shows up because the template is failing to render itself. The key questions are: What does the error in the log mean? and: why doesn't the list template render itself properly?

Here's the tables I'm using...

mysql> describe pubs; +------------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------+-------------+------+-----+---------+----------------+ | pubid | int(11) | | PRI | NULL | auto_increment | | title | mediumtext | YES | | NULL | | | author | mediumtext | YES | | NULL | | | tag | varchar(32) | YES | | NULL | | | year | date | YES | | NULL | | | publisher | varchar(64) | YES | | NULL | | | pages | varchar(16) | YES | | NULL | | | ptype | varchar(8) | YES | | NULL | | | ctype | varchar(8) | YES | | NULL | | | isbn | varchar(16) | YES | | NULL | | | isbn2 | varchar(16) | YES | | NULL | | | coverart | mediumtext | YES | | NULL | | | bcoverart | mediumtext | YES | | NULL | | | frontimage | mediumtext | YES | | NULL | | | price | varchar(16) | YES | | NULL | | | note | int(11) | YES | | NULL | | +------------+-------------+------+-----+---------+----------------+ 16 rows in set (0.00 sec) mysql> describe authors; +------------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------+-------------+------+-----+---------+----------------+ | pubid | int(11) | | PRI | NULL | auto_increment | | canonical | mediumtext | YES | | NULL | | | legalname | mediumtext | YES | | NULL | | | birthplace | varchar(64) | YES | | NULL | | | birthdate | date | YES | | NULL | | | deathdate | date | YES | | NULL | | | pseudos | mediumtext | YES | | NULL | | | emails | mediumtext | YES | | NULL | | | webpages | mediumtext | YES | | NULL | | | note | int(11) | YES | | NULL | | +------------+-------------+------+-----+---------+----------------+ 10 rows in set (0.00 sec) mysql> describe notes -> ; +-------+------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+------------+------+-----+---------+----------------+ | pubid | int(11) | | PRI | NULL | auto_increment | | note | mediumtext | YES | | NULL | | +-------+------------+------+-----+---------+----------------+ 2 rows in set (0.00 sec)

(NOTE: all of the tables have the same primary key "pubid", but it's just an autogenerated int -- it isn't specific to the "pubs" table. Don't blame me, I didn't make the schema)

And here's my Maypole class...

package IsfdbMaypole; use strict; use warnings; use lib qw(/home/hossman/.perllib/lib/perl5/site_perl); use base 'CGI::Maypole'; use Class::DBI::Loader::Relationship; sub debug {1}; IsfdbMaypole->config->uri_base("http://XXXXXXXXXX/index.cgi/"); IsfdbMaypole->config->template_root("/home/hossman/public_html/isfdb-m +aypole/"); IsfdbMaypole->config->application_name("ISFDB Tool (Maypole Prototype) +"); IsfdbMaypole->config->rows_per_page(10); IsfdbMaypole->config->user("hossman"); IsfdbMaypole->config->pass("XXXXXXXXXXXXXXXXXXXXXX"); IsfdbMaypole->setup("dbi:mysql:hossman"); IsfdbMaypole->config->{loader}->relationship($_) for ( # leaving these lines as is causes ./author/list to break, # but ./author/view links to ./notes/view # ./pubs/list on the other hand works fine, but ./pubs/view # doesn't link to ./notes/view "an author has a note", # "a pub has a note", ); 1;

Final note regarding my installation:

When I first got Maypole up and running, I encountered some errors that lead me to realize that Maypole wasn't finding the "factory" templates that it was supposed to use as defaults. They hadn't been installed anywhere on my machine, just left in "~/.cpan/build/Maypole-2.06/templates/factory/. I'm still not sure if they were supposed to get installed somewhere and didn't because I installed Maypole into my private perl lib, or if I was supposed to manually copy them somewhere (none of the docs I've seen suggest that users need to manually copy the factory templates, but I also couldn't find anything in the code that suggested that Maypole would be looking for them anywhere other then the current working directory. So I copied them, set my "template_root", and things started working. I mention this because if it was an installation problem, then perhaps soemthing else went wrong with the instalation as well.

Replies are listed 'Best First'.
Re: Maypole: "has a" causes plugin failure using factory/list
by PodMaster (Abbot) on Jan 23, 2005 at 05:04 UTC
    Try flipping on $Class::DBI::Loader::Relationship::DEBUG=1, to see what Class::DBI::Loader::Relationship is doing, and do the same for Template, which would mean editing your config file and adding (i think this is the right syntaxt)
    view_options DEBUG = DEBUG_ALL
    From the InstallationIssues wiki page, it sounds like you might not have Template::Plugin::Class installed.

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

      Bingo: Template::Plugin::Class was the issue.

      (And now I really feel stupid, because I read that whole page pefore I tried installing last week, but I forgot all about it yesterday)