support MCPKs in M:M:CDBI
Added new Test:: dependencies to Makefile.PL
git-svn-id: http://svn.maypole.perl.org/Maypole/trunk@299
48953598-375a-da11-a14b-
00016c27c3ee
Maypole::Model::CDBI::Plain (Dave Howorth)
- Added Apache::RequestIO to Apache::MVC (michael@diaspora.gen.nz)
- Applied patch to fix length of utf8 documents.
+ - added a new override for the model, fetch_objects.
+ - support MCPKs in CDBI fetch_objects.
2.04 Tue Oct 27 14:00:00 2004
- fixed Apache::MVC version (Randal Schwartz)
CGI::Simple => 0,
Template => 0,
Template::Plugin::Class => 0,
+ Test::MockModule => 0,
+ Test::MockObject => 0,
}, # e.g., Module::Name => 1.1
(
$] >= 5.005
return if $r->{template}; # Authentication has set this, we're done.
$r->{template} = $method;
- $r->objects( [] );
- my $obj = $class->retrieve( $r->{args}->[0] );
- $r->objects( [$obj] ) if $obj;
+ $r->objects([ $class->fetch_objects($r) ]);
$class->$method( $r, $obj, @{ $r->{args} } );
}
This maps between a table name and its associated class.
-=head2 retrieve
+=head2 fetch_objects
-This turns an ID into an object of the appropriate class.
+This method should populate $r->objects from $r->{args}.
=head2 adopt
sub class_of { die "This is an abstract method" }
sub setup_database { die "This is an abstract method" }
+sub fetch_objects { die "This is an abstract method" }
=head2 Commands
=item setup_database
+=item fetch_objects
+
=back
=head1 Additional Commands
return $r->config->loader->_table2class($table);
}
+sub fetch_objects {
+ my ($class,$r)=@_;
+ my @pcs = $class->primary_columns;
+ if ( $#pcs ) {
+ my %pks;
+ @pks{@pcs}=(@{$r->{args}});
+ return $class->retrieve( %pks );
+ }
+ return $class->retrieve( %$r->{args}->[0] );
+}
+
1;