Re: [Maypole-dev] Re: Patch to support compound primary keys

From: Marcus Ramberg (marcus at thefeed.no)
Date: Sun Dec 05 2004 - 22:17:18 GMT


On 5. des. 2004, at 19.12, Dagfinn Ilmari Mannsåker wrote:

> Simon Flack <sf at flacks.net> wrote:
>>
>> On Sun, 05 Dec 2004 17:56:27 +0100, Marcus Ramberg wrote
>
>> I don't think we need to duplicate the code in Maypole::Model::Base.
>> How about something like this:
>
> FWIW, I think this approach is cleaner.

I agree ;) I just hacked this together quickly, and didn't even test it
before jumping into my car to drive home. Glad to see a working
version. Lazyness has prevailed again. Simon, if you don't mind, I'll
apply this. Unless ... Maybe a general populate_objects method or
something would be better? That way you could override how initial
population goes on a class-by-class basis?

Marcus

> sub get_object_id {
> my ( $class, $r ) = @_;
> my @pcs = $class->primary_columns;
> if (@pcs > 1) {
> my %pks;
> @pks{@pcs}=(@{$r->{args}});
> return %pks;
> }
> return $class->SUPER::get_object_id($r);
> }

_______________________________________________
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