[Catalyst] Loading CRUD for all tables
Torsten Seemann
torsten.seemann at infotech.monash.edu.au
Fri Apr 15 06:24:35 CEST 2005
Marcus,
> my %db_class;
> sub default : Private {
> my ($self,$c,$table) = @_;
> %db_class=map {$_->table,$_ }
> $c->comp("MyApp::Model::CDBI")->loader->classes
> unless scalar keys %db_class;
> if ($db_class{$table}) {
> $c->form( optional => [ $class ] );
# minor fix:
$c->form( optional => [ $db_class{$table}->columns ] );
> $c->forward($db_class{$table});
> } else {
> $c->res->output ($table. ' not found');
> }
> }
Ignoring the simple bug fix above, this snippet you produced *almost*
works. Under your scheme the request arguments look like:
$c->req->args = [ 'TABLE_NAME', 'TABLE_ACTION', 'ROW_ID?', ... ]
wherease CDBI.pm & CRUD.pm expect it to look like:
$c->req->args = [ 'TABLE_ACTION', 'ROW_ID?', ... ]
I tried "shift @$c->req->args" but that doesn't work as args() is
a rvalue-only accessor (?).
Any ideas?
--
Torsten Seemann <torsten.seemann at infotech.monash.edu.au>
Victorian Bioinformatics Consortium
More information about the Catalyst
mailing list