From: Tomas Doran Date: Sat, 27 Dec 2008 20:50:12 +0000 (+0000) Subject: Renaming all the attributes, as making them _private breaks multiple plugins. See... X-Git-Tag: 5.8000_05~66 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=d91474f509dab7dce4c3e4328e674ab9fea29284 Renaming all the attributes, as making them _private breaks multiple plugins. See comment for longer term solution.. --- diff --git a/Changes b/Changes index 8030d08..6a40125 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ # This file documents the revision history for Perl extension Catalyst. + - Rename attributes on Catalyst::Dispatcher back to be public + to work correctly with Catalyst::Plugin::Server and + Catalyst::Plugin::Authorization::ACL (t0m) - Fix return value of $c->req->body, which delegates to the body method on the HTTP::Body of the request (t0m) - Test for this (t0m) diff --git a/TODO b/TODO index b304f69..694dc0e 100644 --- a/TODO +++ b/TODO @@ -9,8 +9,7 @@ Pending patches: Back-compat investigation / known issues: - - Catalyst::Plugin::Server is still buggered in various ways.. - - Fix TODO tests in t/aggregate/live_engine_request_body.t + - FIXME notes in Catalyst::Dispatcher - Common engine test failures, look into and get tests into core. @@ -21,6 +20,10 @@ Back-compat investigation / known issues: - Run another round of repository smokes against latest 5.80 trunk, manually go through all the things which are broken (t0m). + - Catalyst::Plugin::Authorization::ACL + - Catalyst::Plugin::Server + - Should hopefully be fixed now.. + - Catalyst-Plugin-Cache dies due to mk_accessors('meta') - Catalyst-Action-REST appears to have real issues, investigate diff --git a/lib/Catalyst/Dispatcher.pm b/lib/Catalyst/Dispatcher.pm index 0b26232..fd17615 100644 --- a/lib/Catalyst/Dispatcher.pm +++ b/lib/Catalyst/Dispatcher.pm @@ -22,16 +22,19 @@ our @PRELOAD = qw/Index Path Regex/; # Postload these action types our @POSTLOAD = qw/Default/; -has _tree => (is => 'rw'); -has _dispatch_types => (is => 'rw', default => sub { [] }, required => 1, lazy => 1); -has _registered_dispatch_types => (is => 'rw', default => sub { {} }, required => 1, lazy => 1); -has _method_action_class => (is => 'rw', default => 'Catalyst::Action'); -has _action_container_class => (is => 'rw', default => 'Catalyst::ActionContainer'); +# FIXME - All of these should be _private attributes, and should have public accessors +# which warn about back-compat if you use them. +has tree => (is => 'rw'); +has dispatch_types => (is => 'rw', default => sub { [] }, required => 1, lazy => 1); +has registered_dispatch_types => (is => 'rw', default => sub { {} }, required => 1, lazy => 1); +has method_action_class => (is => 'rw', default => 'Catalyst::Action'); +has action_container_class => (is => 'rw', default => 'Catalyst::ActionContainer'); +has action_hash => (is => 'rw', required => 1, lazy => 1, default => sub { {} }); +has container_hash => (is => 'rw', required => 1, lazy => 1, default => sub { {} }); +# END FIXME has preload_dispatch_types => (is => 'rw', required => 1, lazy => 1, default => sub { [@PRELOAD] }); has postload_dispatch_types => (is => 'rw', required => 1, lazy => 1, default => sub { [@POSTLOAD] }); -has _action_hash => (is => 'rw', required => 1, lazy => 1, default => sub { {} }); -has _container_hash => (is => 'rw', required => 1, lazy => 1, default => sub { {} }); # Wrap accessors so you can assign a list and it will capture a list ref. around qw/preload_dispatch_types postload_dispatch_types/ => sub { @@ -70,7 +73,7 @@ sub BUILD { my $container = Catalyst::ActionContainer->new( { part => '/', actions => {} } ); - $self->_tree( Tree::Simple->new( $container, Tree::Simple->ROOT ) ); + $self->tree( Tree::Simple->new( $container, Tree::Simple->ROOT ) ); } =head2 $self->preload_dispatch_types @@ -316,7 +319,7 @@ sub _invoke_as_component { my $class = $self->_find_component_class( $c, $component ) || return 0; if ( my $code = $class->can($method) ) { - return $self->_method_action_class->new( + return $self->method_action_class->new( { name => $method, code => $code, @@ -362,7 +365,7 @@ sub prepare_action { # Check out dispatch types to see if any will handle the path at # this level - foreach my $type ( @{ $self->_dispatch_types } ) { + foreach my $type ( @{ $self->dispatch_types } ) { last DESCEND if $type->match( $c, $path ); } @@ -393,7 +396,7 @@ sub get_action { $namespace = join( "/", grep { length } split '/', ( defined $namespace ? $namespace : "" ) ); - return $self->_action_hash->{"${namespace}/${name}"}; + return $self->action_hash->{"${namespace}/${name}"}; } =head2 $self->get_action_by_path( $path ); @@ -406,7 +409,7 @@ sub get_action_by_path { my ( $self, $path ) = @_; $path =~ s/^\///; $path = "/$path" unless $path =~ /\//; - $self->_action_hash->{$path}; + $self->action_hash->{$path}; } =head2 $self->get_actions( $c, $action, $namespace ) @@ -439,11 +442,11 @@ sub get_containers { if ( length $namespace ) { do { - push @containers, $self->_container_hash->{$namespace}; + push @containers, $self->container_hash->{$namespace}; } while ( $namespace =~ s#/[^/]+$## ); } - return reverse grep { defined } @containers, $self->_container_hash->{''}; + return reverse grep { defined } @containers, $self->container_hash->{''}; #return (split '/', $namespace); # isnt this more clear? my @parts = split '/', $namespace; @@ -463,7 +466,7 @@ cannot determine an appropriate URI, this method will return undef. sub uri_for_action { my ( $self, $action, $captures) = @_; $captures ||= []; - foreach my $dispatch_type ( @{ $self->_dispatch_types } ) { + foreach my $dispatch_type ( @{ $self->dispatch_types } ) { my $uri = $dispatch_type->uri_for_action( $action, $captures ); return( $uri eq '' ? '/' : $uri ) if defined($uri); @@ -482,7 +485,7 @@ single action. sub expand_action { my ($self, $action) = @_; - foreach my $dispatch_type (@{ $self->_dispatch_types }) { + foreach my $dispatch_type (@{ $self->dispatch_types }) { my $expanded = $dispatch_type->expand_action($action); return $expanded if $expanded; } @@ -501,7 +504,7 @@ Also, set up the tree with the action containers. sub register { my ( $self, $c, $action ) = @_; - my $registered = $self->_registered_dispatch_types; + my $registered = $self->registered_dispatch_types; #my $priv = 0; #seems to be unused foreach my $key ( keys %{ $action->attributes } ) { @@ -510,13 +513,13 @@ sub register { unless ( $registered->{$class} ) { #some error checking rethrowing here wouldn't hurt. eval { Class::MOP::load_class($class) }; - push( @{ $self->_dispatch_types }, $class->new ) unless $@; + push( @{ $self->dispatch_types }, $class->new ) unless $@; $registered->{$class} = 1; } } # Pass the action to our dispatch types so they can register it if reqd. - foreach my $type ( @{ $self->_dispatch_types } ) { + foreach my $type ( @{ $self->dispatch_types } ) { $type->register( $c, $action ); } @@ -528,14 +531,14 @@ sub register { # Set the method value $container->add_action($action); - $self->_action_hash->{"$namespace/$name"} = $action; - $self->_container_hash->{$namespace} = $container; + $self->action_hash->{"$namespace/$name"} = $action; + $self->container_hash->{$namespace} = $container; } sub _find_or_create_action_container { my ( $self, $namespace ) = @_; - my $tree ||= $self->_tree; + my $tree ||= $self->tree; return $tree->getNodeValue unless $namespace; @@ -571,7 +574,7 @@ sub setup_actions { my @classes = $self->_load_dispatch_types( @{ $self->preload_dispatch_types } ); - @{ $self->_registered_dispatch_types }{@classes} = (1) x @classes; + @{ $self->registered_dispatch_types }{@classes} = (1) x @classes; foreach my $comp ( values %{ $c->components } ) { $comp->register_actions($c) if $comp->can('register_actions'); @@ -606,12 +609,12 @@ sub setup_actions { $walker->( $walker, $_, $prefix ) for $parent->getAllChildren; }; - $walker->( $walker, $self->_tree, '' ); + $walker->( $walker, $self->tree, '' ); $c->log->debug( "Loaded Private actions:\n" . $privates->draw . "\n" ) if $has_private; # List all public actions - $_->list($c) for @{ $self->_dispatch_types }; + $_->list($c) for @{ $self->dispatch_types }; } sub _load_dispatch_types { @@ -627,7 +630,7 @@ sub _load_dispatch_types { eval { Class::MOP::load_class($class) }; Catalyst::Exception->throw( message => qq/Couldn't load "$class"/ ) if $@; - push @{ $self->_dispatch_types }, $class->new; + push @{ $self->dispatch_types }, $class->new; push @loaded, $class; }