Re: [Maypole] Error: "has_a needs a valid column"

From: Sebastian Riedel (sri at oook.de)
Date: Fri Oct 22 2004 - 09:49:36 BST


Am Donnerstag, den 21.10.2004, 18:33 -0700 schrieb Joshua Keroes:
> Can't get some simple code to work. I've searched for this error
> through the Maypole archives, in both Wikis, on google; nothing. I'd
> love some help.
>
>
> === The problem ===
>
> (pulled from apache's log and reformatted for legibility)
>
> [Thu Oct 21 17:08:09 2004] [error]
> has_a needs a valid column at
> /usr/local/lib/site_perl/5.8.1/Class/DBI/Relationship/HasA.pm line 12
> Compilation failed in require at (eval 9) line 3.
> Use of uninitialized value in subroutine entry at
> /usr/local/lib/site_perl/5.8.1/Maypole.pm line 99.
> file error - projects: not found at
> /usr/local/lib/site_perl/5.8.1/Maypole/View/Base.pm line 68.
>
> [Thu Oct 21 18:05:32 2004] [error]
> [client 127.0.0.1] File does not exist: /usr/local/apache/www/projects
>
>
> === The basics ===
>
> OSX machine running mysql-12.22 (fink), perl-5.8.1 (src), Apache/1.3.31
> + mod_perl/1.29 (src)
>
> Class::DBI, Class::DBI::Loader::mysql, Class::DBI::mysql, DBD::mysql,
> TT2, and the rest of the Maypole framework installed (or at least I'm
> pretty sure I have it all in there).
>
>
> === MySQL setup ===
>
> Both of these are in database "projects".
>
> CREATE TABLE projects (
> project_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
> name VARCHAR(128) NOT NULL,
> cfr MEDIUMINT,
> description TEXT,
> start_date DATE NOT NULL,
> end_date DATE,
> status TEXT,
> status_date DATE,
> eng_id INT REFERENCES engineers (eng_id),
> is_complete TINYINT(1)
> ) TYPE=InnoDb;
>
> CREATE TABLE engineers (
> eng_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
> fname VARCHAR(128) NOT NULL,
> lname VARCHAR(128) NOT NULL
> ) TYPE=InnoDb;

Rename tables to "project" and "engineer".

>
> These are accessible by user "projects"/password "projects". I have
> confirmed this on the command-line.
>
>
> === Perl setup ===
>
> package Maypole::Projects;
>
> our $VERSION = '0.01';
>
> use base 'Apache::MVC';
> use Class::DBI::Loader::Relationship;
>
> __PACKAGE__->setup( "dbi:mysql:projects", "projects", "projects" );
> __PACKAGE__->config->{uri_base} = "http://localhost/projects/";

you should also set {template_root}, not really needed if your Apache is
configured right, but it's safer.

> __PACKAGE__->config->{rows_per_page} = 20;
> __PACKAGE__->config->{loader}->relationship($_) for (
> "a project has engineers",
> );
>
> Maypole::Projects::projects->untaint_columns(
> printable => [qw/name description status/],
> date => [qw/start_date end_date status_date/],
> int => [qw/project_id cfr eng_id is_complete/],
> );

Class names are CamelCase, so use "Maypole::Projects::Project".

>
> Maypole::Projects::engineers->untaint_columns(
> printable => [qw/fname lname/],
> int => [qw/eng_id/],
> );

"Maypole::Projects::Engineer".

>
> 1;
>
>
> === Apache setup ===
>
> Nothing fancy, just added this to the bottom of httpd.conf:
>
> <Location /projects/>
> SetHandler perl-script
> PerlHandler Maypole::Projects
> </Location>
>
>
> === WHISKEY TANGO FOXTROT AMIGOS ===
>
> Maybe my use of setup() is wonky. I haven't seen any examples that also
> pass the username and password to mysql via setup() although Simon
> mentioned in a changelog that this would be ok. If my use of setup() is
> wonky, then perhaps CDBI::Loader::Relationship or a superclass is
> failing to log in and/or properly use the projects database.
>
> I haven't installed any templates. I was expecting that some default
> templates would automatically be used.

copy templates to the specified {template_root}.

>
> Any ideas what I need to do to get CDBI::Loader::Relationship to work
> happily?
>
> Thanks everyone,
> Joshua
>
>
> _______________________________________________
> maypole mailing list
> maypole at lists.netthink.co.uk
> http://lists.netthink.co.uk/listinfo/maypole

sebastian

_______________________________________________
maypole mailing list
maypole at lists.netthink.co.uk
http://lists.netthink.co.uk/listinfo/maypole



This archive was generated by hypermail 2.1.3 : Thu Feb 24 2005 - 22:25:56 GMT