X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FSchema.pm;h=9105477748396ca9834616b80d6322b6e59f5492;hb=3c0d364c44b71763c8ebdb1467e9a1cb5c661dd5;hp=e0cb8cc4cfaa452d84a03d361a211418fe57ac3d;hpb=2053ab2a47d0cbf3db670003d01a9b4650bc46d6;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/lib/DBIx/Class/Schema.pm b/lib/DBIx/Class/Schema.pm index e0cb8cc..9105477 100644 --- a/lib/DBIx/Class/Schema.pm +++ b/lib/DBIx/Class/Schema.pm @@ -4,6 +4,7 @@ use strict; use warnings; use Carp::Clan qw/^DBIx::Class/; +use Scalar::Util qw/weaken/; use base qw/DBIx::Class/; @@ -63,7 +64,7 @@ particular which module inherits off which. =back -Registers a class which isa L. Equivalent to +Registers a class which isa DBIx::Class::ResultSourceProxy. Equivalent to calling: $schema->register_source($moniker, $component_class->result_source_instance); @@ -94,12 +95,13 @@ sub register_source { $reg{$moniker} = $source; $self->source_registrations(\%reg); $source->schema($self); + weaken($source->{schema}) if ref($self); if ($source->result_class) { my %map = %{$self->class_mappings}; $map{$source->result_class} = $moniker; $self->class_mappings(\%map); } -} +} =head2 class @@ -207,7 +209,7 @@ need to add C before your load_classes call. Example: My::Schema->load_classes(); # loads My::Schema::CD, My::Schema::Artist, - # etc. (anything under the My::Schema namespace) + # etc. (anything under the My::Schema namespace) # loads My::Schema::CD, My::Schema::Artist, Other::Namespace::Producer but # not Other::Namespace::LinerNotes nor My::Schema::Track @@ -263,9 +265,9 @@ sub load_classes { my $comp_class = "${prefix}::${comp}"; eval "use $comp_class"; # If it fails, assume the user fixed it if ($@) { - $comp_class =~ s/::/\//g; + $comp_class =~ s/::/\//g; die $@ unless $@ =~ /Can't locate.+$comp_class\.pm\sin\s\@INC/; - warn $@ if $@; + warn $@ if $@; } push(@to_register, [ $comp, $comp_class ]); } @@ -569,8 +571,8 @@ sub txn_do { $self->txn_begin; # If this throws an exception, no rollback is needed my $wantarray = wantarray; # Need to save this since the context - # inside the eval{} block is independent - # of the context that called txn_do() + # inside the eval{} block is independent + # of the context that called txn_do() eval { # Need to differentiate between scalar/list context to allow for @@ -599,7 +601,7 @@ sub txn_do { my $rollback_error = $@; my $exception_class = "DBIx::Class::Storage::NESTED_ROLLBACK_EXCEPTION"; $self->throw_exception($error) # propagate nested rollback - if $rollback_error =~ /$exception_class/; + if $rollback_error =~ /$exception_class/; $self->throw_exception( "Transaction aborted: $error. Rollback failed: ${rollback_error}" @@ -674,7 +676,7 @@ sub populate { =head2 throw_exception -=over 4 +=over 4 =item Arguments: $message