From 0acf11b08135636930349a74d3cdf8b01c849496 Mon Sep 17 00:00:00 2001 From: Aaron Trevena Date: Tue, 11 Oct 2005 18:42:35 +0000 Subject: [PATCH] applied peters fix for bug # 14566 git-svn-id: http://svn.maypole.perl.org/Maypole/trunk@392 48953598-375a-da11-a14b-00016c27c3ee --- Changes | 3 +++ MANIFEST | 1 + lib/Maypole/Model/CDBI.pm | 32 ++++++++++++++++++-------------- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/Changes b/Changes index e8706ad..ebc146b 100644 --- a/Changes +++ b/Changes @@ -16,7 +16,10 @@ For information about current developments and future releases, see: add() alias to push() in Mp::Headers (wishlist 14142) Fixed inheritance issues in Mp::Application - Mp::App now manipulates the caller's @ISA directly, and doesn't inject itself into the chain (bugs 12923 & 14120) + Added new path processing methods for ssl and default table/action Moved ar accessor to Apache::MVC (bug 14014) + Refactored core to support further development in 2.11 and onwards + Fixed related_class method (bug 14566) 2.10 Tue 19 Jul 2005 Multiple Template Paths added ( http://rt.cpan.org/NoAuth/Bug.html?id=13447 ) diff --git a/MANIFEST b/MANIFEST index 6647351..5f23cef 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1,5 +1,6 @@ Changes ex/BeerDB.pm +ex/beerdb.sql lib/Apache/MVC.pm lib/CGI/Maypole.pm lib/Maypole.pm diff --git a/lib/Maypole/Model/CDBI.pm b/lib/Maypole/Model/CDBI.pm index c80a290..8de426a 100644 --- a/lib/Maypole/Model/CDBI.pm +++ b/lib/Maypole/Model/CDBI.pm @@ -85,21 +85,25 @@ sub related { } sub related_class { - my ( $self, $r, $accessor ) = @_; + my ( $self, $r, $accessor ) = @_; + my $meta = $self->meta_info; + my @rels = keys %$meta; + my $related; + foreach (@rels) { + $related = $meta->{$_}{$accessor}; + last if $related; + } + return unless $related; + + my $mapping = $related->{args}->{mapping}; + if ( $mapping and @$mapping ) { + return $related->{foreign_class}->meta_info('has_a')->{$$mapping[0]}->{foreign_class}; + } + else { + return $related->{foreign_class}; + } + } - my $related = $self->meta_info( has_many => $accessor ) || - $self->meta_info( has_a => $accessor ) || - return; - - my $mapping = $related->{args}->{mapping} || []; - if ( @$mapping ) { - return $related->{foreign_class}->meta_info('has_a')->{ $$mapping[0] } - ->{foreign_class}; - } - else { - return $related->{foreign_class}; - } -} sub do_edit : Exported { my ( $self, $r ) = @_; -- 2.39.5