[Catalyst-commits] r8960 - in Catalyst-Runtime/5.80/trunk: . lib/Catalyst

t0m at dev.catalyst.perl.org t0m at dev.catalyst.perl.org
Sat Dec 27 20:50:12 GMT 2008


Author: t0m
Date: 2008-12-27 20:50:12 +0000 (Sat, 27 Dec 2008)
New Revision: 8960

Modified:
   Catalyst-Runtime/5.80/trunk/Changes
   Catalyst-Runtime/5.80/trunk/TODO
   Catalyst-Runtime/5.80/trunk/lib/Catalyst/Dispatcher.pm
Log:
Renaming all the attributes, as making them _private breaks multiple plugins. See comment for longer term solution..

Modified: Catalyst-Runtime/5.80/trunk/Changes
===================================================================
--- Catalyst-Runtime/5.80/trunk/Changes	2008-12-27 19:44:45 UTC (rev 8959)
+++ Catalyst-Runtime/5.80/trunk/Changes	2008-12-27 20:50:12 UTC (rev 8960)
@@ -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)

Modified: Catalyst-Runtime/5.80/trunk/TODO
===================================================================
--- Catalyst-Runtime/5.80/trunk/TODO	2008-12-27 19:44:45 UTC (rev 8959)
+++ Catalyst-Runtime/5.80/trunk/TODO	2008-12-27 20:50:12 UTC (rev 8960)
@@ -9,8 +9,7 @@
   
 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 @@
   - 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

Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst/Dispatcher.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst/Dispatcher.pm	2008-12-27 19:44:45 UTC (rev 8959)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst/Dispatcher.pm	2008-12-27 20:50:12 UTC (rev 8960)
@@ -22,16 +22,19 @@
 # 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 @@
   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 @@
     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 @@
         # 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 @@
 
     $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 @@
     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 @@
 
     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 @@
 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 @@
 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 @@
 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 @@
         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 @@
     # 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 @@
 
     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 @@
         $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 @@
         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;
     }




More information about the Catalyst-commits mailing list