Hi.
Some person in #maypole alerted me to the fact that
Maypole::Model::Base::process
will break with compound primary keys, because such a construct requires
retrieve with named columns. I've attached a patch below that will add a
process to CDBI.pm which will check if a column has more than 1 primary
key, and map primary keys to $r->{args} if so.
What do you think? Should we commit this? Is it dirty? ;)
Marcus
Index: CDBI.pm
===================================================================
--- CDBI.pm (revision 292)
+++ CDBI.pm (working copy)
@@ -73,6 +73,23 @@
=cut
+sub process {
+ my ( $class, $r ) = @_;
+ if (@{$class->primary_columns} > 1) {
+ my $method = $r->action;
+ return if $r->{template}; # Authentication has set this,
we're done.
+ $r->{template} = $method;
+ $r->objects( [] );
+ my %pks;
+ @pks{@$class->primary_keys}=(@$r->{args});
+ my $obj = $class->retrieve( %pks);
+ $r->objects( [$obj] ) if $obj;
+ $class->$method( $r, $obj, @{ $r->{args} } );
+ } else {
+ return $class->SUPER::process(@_);
+ }
+}
+
sub related {
my ( $self, $r ) = @_;
return keys %{ $self->meta_info('has_many') || {} };
_______________________________________________
maypole-dev mailing list
maypole-dev at lists.netthink.co.uk
http://lists.netthink.co.uk/listinfo/maypole-dev
This archive was generated by hypermail 2.1.3 : Thu Feb 24 2005 - 22:25:57 GMT