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:
|
|---|
| 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 | |
by hossman (Prior) on Jan 23, 2005 at 17:14 UTC |