Discussion:
Unusual error involving CDBI - DBIx:CF - FromCGI
Torsten Seemann
2005-02-11 02:38:38 UTC
Permalink
Hi,

I just put together a basic Maypole app using automatic setup
to a MySQL InnoDB database. Actions "list" and "view" seem to
work ok, but any create or edit seem to do nothing, ie "do_edit".

The following errors appear in the web server error log (and also when I
use Maypole::CLI). Also appended is a table schema and my Maypole class.

Any ideas what would cause these errors or cause do_edit to fail?

Thanks for any help!

--Torsten


[Fri Feb 11 11:45:17 2005] [error] Loaded tables:
gel,gene,oligo,organism,pcr,person at
/usr/lib/perl5/site_perl/5.8.3/Maypole/Model/CDBI.pm line 244., referer:
http://localhost/boyligo/maypole.cgi/person/do_edit/

[Fri Feb 11 11:45:17 2005] [error] Can't insert new
Boypole::Person: DBD::mysql::st execute failed: Duplicate entry '' for
key 2 [for Statement "INSERT INTO person (id), referer:
http://localhost/boyligo/maypole.cgi/person/do_edit/

[Fri Feb 11 11:45:17 2005] [error] VALUES (?),
referer: http://localhost/boyligo/maypole.cgi/person/do_edit/

[Fri Feb 11 11:45:17 2005] [error] "] at
/usr/lib/perl5/site_perl/5.8.3/DBIx/ContextualFetch.pm line 51.,
referer: http://localhost/boyligo/maypole.cgi/person/do_edit/

[Fri Feb 11 11:45:17 2005] [error] at
/usr/lib/perl5/site_perl/5.8.3/Class/DBI/FromCGI.pm line 246, referer:
http://localhost/boyligo/maypole.cgi/person/do_edit/


CREATE TABLE `person` (
`login` VARCHAR(100) UNIQUE NOT NULL,
`name` VARCHAR(100) NOT NULL,
`email` VARCHAR(100) NOT NULL,
`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY
) ENGINE=InnoDB;


package Boypole;
use Maypole::Application qw(-Debug);
use Class::DBI::Loader::Relationship;
__PACKAGE__->setup("dbi:mysql:XXX", "YYY", "ZZZ");
__PACKAGE__->config->application_name('Boyligo');
__PACKAGE__->config->uri_base( ETC );
__PACKAGE__->config->template_root( ETC );
1;
Dave Howorth
2005-02-11 10:31:00 UTC
Permalink
Post by Torsten Seemann
I just put together a basic Maypole app using automatic setup
to a MySQL InnoDB database. Actions "list" and "view" seem to
work ok, but any create or edit seem to do nothing, ie "do_edit".
The following errors appear in the web server error log (and also when I
use Maypole::CLI). Also appended is a table schema and my Maypole class.
Any ideas what would cause these errors or cause do_edit to fail?
You need to call untaint_columns so that do_edit knows how to interpret
your data. Look at
http://search.cpan.org/~simonflk/Maypole-2.09/lib/Maypole/Manual/StandardTemplates.pod#Digression_on_Class::DBI::FromCGI
and/or check out the BeerDB example.

HTH, Dave
Dave Howorth
2005-02-11 11:00:09 UTC
Permalink
Post by Torsten Seemann
I just put together a basic Maypole app using automatic setup
to a MySQL InnoDB database. Actions "list" and "view" seem to
work ok, but any create or edit seem to do nothing, ie "do_edit".
The following errors appear in the web server error log (and also when I
use Maypole::CLI). Also appended is a table schema and my Maypole class.
Any ideas what would cause these errors or cause do_edit to fail?
CREATE TABLE `person` (
`login` VARCHAR(100) UNIQUE NOT NULL,
`name` VARCHAR(100) NOT NULL,
`email` VARCHAR(100) NOT NULL,
`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY
) ENGINE=InnoDB;
Thinking about it a little more, I believe that as well as calling
untaint_columns you'll actually need to write a custom do_edit action
because of that UNIQUE constraint. This is outside my experience, but
AFAIK neither CDBI nor Maypole has any means of generating a
'pseudo-CGI-validation error' to give the user another chance without
you writing some extra code.

Cheers, Dave

Loading...