[Catalyst-commits] r10315 - in trunk/Catalyst-Model-DBIC-Schema: .
lib/Catalyst/Helper/Model/DBIC lib/Catalyst/Model/DBIC
lib/Catalyst/Model/DBIC/Schema/Trait
caelum at dev.catalyst.perl.org
caelum at dev.catalyst.perl.org
Wed May 27 17:56:51 GMT 2009
Author: caelum
Date: 2009-05-27 17:56:51 +0000 (Wed, 27 May 2009)
New Revision: 10315
Modified:
trunk/Catalyst-Model-DBIC-Schema/Changes
trunk/Catalyst-Model-DBIC-Schema/Makefile.PL
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Helper/Model/DBIC/Schema.pm
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema.pm
trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema/Trait/Replicated.pm
Log:
remove MX::Object::Pluggable
Modified: trunk/Catalyst-Model-DBIC-Schema/Changes
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/Changes 2009-05-27 13:58:45 UTC (rev 10314)
+++ trunk/Catalyst-Model-DBIC-Schema/Changes 2009-05-27 17:56:51 UTC (rev 10315)
@@ -1,14 +1,14 @@
Revision history for Perl extension Catalyst::Model::DBIC::Schema
-0.24 Mon May 25 08:44:09 PDT 2009
+0.24 Wed May 27 17:55:50 UTC 2009
- Add tests for issues with Class::C3 which are caused to
applications which use new Catalyst but old DBIC, and have
use Class::C3 in the MyApp class (t0m)
- die on empty schema
- create=dynamic deprecation warning
- conversion to Moose
- - cursor caching support (via ::Role::Caching)
- - ::Storage::Replicated support (via ::Role::Replicated)
+ - cursor caching support (via ::Trait::Caching)
+ - ::Storage::Replicated support (via ::Trait::Replicated)
- switch to hashref connect_info for DBIC 8100
- better helper option parsing, with support for more options
- helper passes loader opts to dynamic schemas
Modified: trunk/Catalyst-Model-DBIC-Schema/Makefile.PL
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/Makefile.PL 2009-05-27 13:58:45 UTC (rev 10314)
+++ trunk/Catalyst-Model-DBIC-Schema/Makefile.PL 2009-05-27 17:56:51 UTC (rev 10315)
@@ -3,12 +3,11 @@
name 'Catalyst-Model-DBIC-Schema';
all_from 'lib/Catalyst/Model/DBIC/Schema.pm';
-requires 'DBIx::Class' => '0.08102';
+requires 'DBIx::Class' => '0.08103';
requires 'Catalyst::Runtime' => '5.80003';
requires 'Moose';
requires 'Moose::Autobox';
requires 'MooseX::Types';
-requires 'MooseX::Object::Pluggable' => '0.0011';
requires 'namespace::clean';
requires 'Carp::Clan';
requires 'List::MoreUtils';
Modified: trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Helper/Model/DBIC/Schema.pm
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Helper/Model/DBIC/Schema.pm 2009-05-27 13:58:45 UTC (rev 10314)
+++ trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Helper/Model/DBIC/Schema.pm 2009-05-27 17:56:51 UTC (rev 10315)
@@ -568,7 +568,7 @@
Contributors:
-Rafael Kitover, C<<rkitover at cpan.org>>
+Rafael Kitover, C<rkitover at cpan.org>
=head1 LICENSE
Modified: trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema/Trait/Replicated.pm
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema/Trait/Replicated.pm 2009-05-27 13:58:45 UTC (rev 10314)
+++ trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema/Trait/Replicated.pm 2009-05-27 17:56:51 UTC (rev 10315)
@@ -43,17 +43,6 @@
C<1> by default, meaning that you have the same chance of reading from master as
you do from replicants. Set to C<0> to turn off reads from master.
-=head1 NOTE ON L<DBIx::Class> VERSIONS PRIOR TO 0.08103
-
-This trait will work, however, any C<::Storage::Replicated> options in
-L<Catalyst::Model::DBIC::Schema/connect_info> will be ignored, master
-connect_info will not be merged to replicants, and
-L<DBIx::Class::Storage::DBI::Replicated::Balancer::First> will be used instead,
-with all your reads going only to one of your replicants. You'll also get some
-warnings. The C<Caching> trait will also not work.
-
-Please upgrade.
-
=head1 CONFIG PARAMETERS
=head2 replicants
Modified: trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema.pm
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema.pm 2009-05-27 13:58:45 UTC (rev 10314)
+++ trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema.pm 2009-05-27 17:56:51 UTC (rev 10315)
@@ -3,7 +3,6 @@
use Moose;
use mro 'c3';
extends 'Catalyst::Model';
-with 'MooseX::Object::Pluggable';
our $VERSION = '0.24';
@@ -13,11 +12,12 @@
use Scalar::Util 'reftype';
use MooseX::ClassAttribute;
use Moose::Autobox;
+use Moose::Util ();
use Catalyst::Model::DBIC::Schema::Types
qw/ConnectInfo SchemaClass CursorClass/;
-use MooseX::Types::Moose qw/ArrayRef Str ClassName/;
+use MooseX::Types::Moose qw/ArrayRef Str ClassName Undef/;
use namespace::clean -except => 'meta';
@@ -294,27 +294,26 @@
=head2 traits
-Array of Traits to apply at BUILD time. Traits are relative to the
-C<<MyApp::Model::DB::Trait::> then C<<Catalyst::Model::DBIC::Schema::Trait::>>
-namespaces, unless prefixed with C<+> in which case they are taken to be a
-fully qualified name. E.g.:
+Array of Traits to apply to the instance. Traits are L<Moose::Role>s.
+They are relative to the C<< MyApp::Model::DB::Trait:: >>, then the C<<
+Catalyst::Model::DBIC::Schema::Trait:: >> namespaces, unless prefixed with C<+>
+in which case they are taken to be a fully qualified name. E.g.:
+
traits Caching
traits +MyApp::DB::Trait::Foo
-This is done using L<MooseX::Object::Pluggable>.
-
A new instance is created at application time, so any consumed required
attributes, coercions and modifiers will work.
Traits are applied before setup, schema and connection are set.
-C<ref $self> will be an anon class if any traits are applied.
+C<ref $self> will be an anon class if any traits are applied, C<<
+$self->_original_class_name >> will be the original class.
-You cannot modify C<new> or C<BUILD>, modify C<setup> instead.
+You cannot modify C<BUILD> in a trait, as that is when traits are applied,
+modify L</setup> instead.
-L</ACCEPT_CONTEXT> and L</finalize> can also be modified.
-
Traits that come with the distribution:
=over 4
@@ -405,6 +404,8 @@
has traits => (is => 'ro', isa => ArrayRef|Str);
+has _trait_fqns => (is => 'ro', isa => ArrayRef|Undef, lazy_build => 1);
+
has _default_cursor_class => (
is => 'ro',
isa => CursorClass,
@@ -412,6 +413,13 @@
coerce => 1
);
+has _original_class_name => (
+ is => 'ro',
+ required => 1,
+ isa => Str,
+ default => sub { blessed $_[0] },
+);
+
sub BUILD {
my $self = shift;
my $class = ref $self;
@@ -435,10 +443,9 @@
. " ".$self->connect_info->{cursor_class}.": $@";
}
- $self->_plugin_ns('Trait');
+ Moose::Util::apply_all_roles($self, $self->_trait_fqns->flatten)
+ if $self->_trait_fqns;
- $self->load_plugins($self->traits->flatten) if $self->traits;
-
$self->setup;
$self->composed_schema($schema_class->compose_namespace($class));
@@ -465,7 +472,7 @@
=head2 setup
-Called at C<<BUILD>> time before configuration.
+Called at C<BUILD>> time before configuration.
=cut
@@ -481,7 +488,7 @@
=head2 ACCEPT_CONTEXT
-Point of extension for doing things at C<<$c->model>> time, returns the model
+Point of extension for doing things at C<< $c->model >> time, returns the model
instance, see L<Catalyst::Manual::Intro> for more information.
=cut
@@ -531,6 +538,36 @@
}
}
+sub _build__trait_fqns {
+ my $self = shift;
+ my $class = $self->_original_class_name;
+ my $base = 'Trait';
+
+ my @names = $self->traits->flatten if $self->traits;
+ return unless @names;
+
+ my @search_ns = grep !/^(?:Moose|Class::MOP)::/,
+ $class->meta->class_precedence_list;
+
+ my @traits;
+
+ OUTER: for my $name (@names) {
+ if ($name =~ /^\+(.*)/) {
+ push @traits, $1;
+ next;
+ }
+ for my $ns (@search_ns) {
+ my $full = "${ns}::${base}::${name}";
+ if (eval { Class::MOP::load_class($full) }) {
+ push @traits, $full;
+ next OUTER;
+ }
+ }
+ }
+
+ return @traits ? \@traits : undef;
+}
+
__PACKAGE__->meta->make_immutable;
=head1 SEE ALSO
@@ -557,7 +594,7 @@
Contributors:
-Rafael Kitover, C<<rkitover at cpan.org>>
+Rafael Kitover, C<rkitover at cpan.org>
=head1 COPYRIGHT
@@ -567,3 +604,4 @@
=cut
1;
+# vim:sts=4 sw=4:
More information about the Catalyst-commits
mailing list