On 9/12/05, Peter Speltz <[EMAIL PROTECTED]> wrote:
> On 9/11/05, Frank Carnovale
> <[EMAIL PROTECTED]> wrote:
> > Peter,
> >
> > The original related_class method looked like an unfinished experiment to
> > me, and yes it is badly named because it confines itself to has_many's only.
> >
> > If it's any help, here is a chunk from our application model class which I
> > coded earlier this year. I vaguely remember discovering that related_class
> > as it stood then was broken and also never used anywhere, so I fixed it and
> > kept on bravely not using it.
> > Right now I would have to invest serious time trying to re-learn both the
> > original code and my alleged fix, which involved quite a bit of Class::DBI
> > digging. So I can't make any useful comment right now about why I thought
> > it was broken and why my version was any better, but here it is..
> > ###########################
> > # override this Maypole::Model::CDBI method which is broken there, but
> > never used.
> > sub related_class {
> > my ( $self, $accessor ) = @_;
> > my $meta_has_many = $self->meta_info('has_many') || return;
> > my $meta_accessor = $meta_has_many->{$accessor} || return;
> > my $mapping = $meta_accessor->{args}->{mapping} || [];
> > return
> > $meta_accessor->{foreign_class}->meta_info('has_a')->{$$mapping[0]}->{foreign_class}
> > if @$mapping;
> > return $meta_accessor->{foreign_class};
> > }
> > ############################
> >
>
> Hi. Thanks Frank. I see you fixed the @$mapping bug. The cuurent
> version uses @$mapping without defining it with an "|| [] " first. So
> if you call related_class with a has_a accessor it will die.
>
> Yours only works for has_many. I like it to work for any , including
> custom ones.
>
I have a related_class_and_rel_type() method in
Class::DBI::FormBuilder::Meta::Table (part of the CDBI::FB distro).
Same idea. But I don't understand CDBI relationships well enough at
the moment to say it will work for custom relationships. It works for
has_a and has_many, and probably might_have.
Is anyone aware of a similar method elsewhere in the CDBI stack?
I didn't realise related_class() wasn't used anywhere by Maypole. If
so, it might be worth re-naming it, or deprecating it? It does seem to
be broken for has_a's at the moment. Anybody using it?
I've added the @$mapping bug to rt.
d.
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Maypole-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/maypole-devel