Merge 'trunk' into 'deprecate_appclass_actions'
Tomas Doran [Mon, 7 Sep 2009 20:35:57 +0000 (20:35 +0000)]
r11024@t0mlaptop (orig r11023):  caelum | 2009-08-01 20:04:08 +0100
allow uri_for($controller_instance)
r11035@t0mlaptop (orig r11034):  t0m | 2009-08-05 20:39:01 +0100
Require perl 5.8.6
r11038@t0mlaptop (orig r11037):  hobbs | 2009-08-06 10:57:02 +0100
Add a method to the stats object to get the request start time.

r11048@t0mlaptop (orig r11047):  t0m | 2009-08-07 01:15:04 +0100
Fix the perl version required there also
r11049@t0mlaptop (orig r11048):  t0m | 2009-08-07 01:24:17 +0100
Blow up if we're in author mode and don't have the right M::I extensions
r11050@t0mlaptop (orig r11049):  t0m | 2009-08-07 01:57:21 +0100
Bump MX::MA dep for anon class tests
r11058@t0mlaptop (orig r11057):  gbjk | 2009-08-07 17:45:03 +0100
DispatchType::Chained fix for default args attribute to handle Args(0) vs Args() at depth.

r11059@t0mlaptop (orig r11058):  gbjk | 2009-08-07 18:17:15 +0100
DispatchType::Chained fix failing test of Args(0) vs Args(0) on surface

r11062@t0mlaptop (orig r11061):  gbjk | 2009-08-07 22:17:22 +0100
Engine::HTTP - Fix paths for HTTP requests with scheme and domain in URI.

r11064@t0mlaptop (orig r11063):  groditi | 2009-08-08 22:54:04 +0100
make debug output prettier with large widths
r11065@t0mlaptop (orig r11064):  groditi | 2009-08-08 22:54:46 +0100
oops debug output got leaked in
r11069@t0mlaptop (orig r11068):  t0m | 2009-08-09 13:36:20 +0100
Fix RT#48555
r11070@t0mlaptop (orig r11069):  t0m | 2009-08-09 13:36:55 +0100
Updates changelog
r11071@t0mlaptop (orig r11070):  t0m | 2009-08-09 15:22:21 +0100
Rewrite fixes for RT#48555
r11123@t0mlaptop (orig r11122):  t0m | 2009-08-11 22:49:37 +0100
Unfuck Catalyst::View::JSON
r11125@t0mlaptop (orig r11124):  t0m | 2009-08-11 23:32:47 +0100
Apply patch from RT#48623 to fix headers in Engine::HTTP
r11127@t0mlaptop (orig r11126):  rjbs | 2009-08-12 00:33:18 +0100
svn merge -r 11123:11125 branches/locate_components/ trunk/
r11128@t0mlaptop (orig r11127):  rjbs | 2009-08-12 00:34:12 +0100
add changelog entry for merged locate_components branch
r11130@t0mlaptop (orig r11129):  t0m | 2009-08-12 01:15:51 +0100
Tiny change to make the error make more sense
r11132@t0mlaptop (orig r11131):  t0m | 2009-08-12 02:09:09 +0100
Split test out into a more proper app, so that the test no longer relies on the metaclass initialization hacking occurring in ->setup_component, as I want to move it
r11133@t0mlaptop (orig r11132):  t0m | 2009-08-12 02:11:07 +0100
Blow up rather than failing to call ->can if everything is totally screwed
r11134@t0mlaptop (orig r11133):  rafl | 2009-08-12 03:54:52 +0100
Fix POD refering to CGI::Cookie. We're using CGI::Simple::Cookie.

Courtesy of Forrest Cahoon.
r11135@t0mlaptop (orig r11134):  t0m | 2009-08-12 12:03:06 +0100
Make the code much clearer about what is going on, and remove the horrible map and grep which I hated.
r11140@t0mlaptop (orig r11139):  rafl | 2009-08-16 10:19:58 +0100
Do at least one (possibly empty) write when reading the response body from a filehandle.
r11145@t0mlaptop (orig r11144):  jshirley | 2009-08-17 22:33:17 +0100
Adding and documented X-Forwarded-Port
r11146@t0mlaptop (orig r11145):  t0m | 2009-08-17 23:08:19 +0100
Capitalisation fixes in Changelog
r11147@t0mlaptop (orig r11146):  t0m | 2009-08-17 23:11:34 +0100
Add _component_name stuff to Changes
r11148@t0mlaptop (orig r11147):  jshirley | 2009-08-17 23:13:05 +0100
Conflict resolution
r11149@t0mlaptop (orig r11148):  hobbs | 2009-08-17 23:24:46 +0100
Changelog for r11037

r11150@t0mlaptop (orig r11149):  t0m | 2009-08-18 00:14:38 +0100
Switch to catalyst_component_name
r11154@t0mlaptop (orig r11153):  ferz | 2009-08-18 07:55:14 +0100
Test case using Exception::Class

r11155@t0mlaptop (orig r11154):  ferz | 2009-08-18 12:19:40 +0100
drop POD comments.

r11166@t0mlaptop (orig r11165):  t0m | 2009-08-19 20:03:01 +0100
Move test to make more sense in my idea of the naming scheme - t/dead_ is for tests which check the app pukes, which this shouldn't
r11167@t0mlaptop (orig r11166):  t0m | 2009-08-19 20:04:59 +0100
Fail commit was fail. Back out the part I didn't want
r11168@t0mlaptop (orig r11167):  t0m | 2009-08-19 20:10:06 +0100
Remove r11058 - the commit message is lies, it does not fix the TODO test
r11169@t0mlaptop (orig r11168):  t0m | 2009-08-19 21:21:44 +0100
Back out r11057 which breaks one of the chained tests, whilst not fixing the bug in question
r11170@t0mlaptop (orig r11169):  t0m | 2009-08-19 21:29:16 +0100
Clean up test app for the exception test, as we don't want to depend on Test::Class thanks
r11171@t0mlaptop (orig r11170):  rafl | 2009-08-19 21:45:45 +0100
Changelog Engine::finalize_body changes.
r11181@t0mlaptop (orig r11180):  gbjk | 2009-08-21 14:07:54 +0100
Changelog update for previous Catalyst::Engine::HTTP fix.

r11182@t0mlaptop (orig r11181):  rafl | 2009-08-21 16:51:26 +0100
Now we don't have the broken restarter engine anymore, we conflict with old Catalyst::Devel versions, that don't have the new restarter yet.
r11183@t0mlaptop (orig r11182):  rafl | 2009-08-21 17:12:57 +0100
Conflict with the latest mason view, which blows up because of the new component_name constructor arg.
r11184@t0mlaptop (orig r11183):  rafl | 2009-08-21 17:13:05 +0100
Version 5.80008.
r11190@t0mlaptop (orig r11189):  t0m | 2009-08-21 20:54:58 +0100
Fix and tests for big issue in 5.80008
r11191@t0mlaptop (orig r11190):  rafl | 2009-08-21 21:28:30 +0100
Version 5.80009.
r11193@t0mlaptop (orig r11192):  rafl | 2009-08-21 21:55:25 +0100
DOH! do more than one read, if necessary.
r11194@t0mlaptop (orig r11193):  rafl | 2009-08-21 22:22:36 +0100
Do what we want instead of exiting a sub via last.
r11195@t0mlaptop (orig r11194):  rafl | 2009-08-21 22:22:45 +0100
Add test for sending the body from a filehandle with more data than the default chunksize of 64k.
r11196@t0mlaptop (orig r11195):  rafl | 2009-08-21 22:31:38 +0100
Changelogging.
r11197@t0mlaptop (orig r11196):  rafl | 2009-08-21 22:41:05 +0100
Version 5.80010.
r11215@t0mlaptop (orig r11214):  rafl | 2009-08-22 20:56:53 +0100
Remove leftovers of the restarter engine.

The removed code caused test failures, which weren't apparent due to installed
copies still being available in everyone's @INC.
r11218@t0mlaptop (orig r11217):  rafl | 2009-08-23 12:46:42 +0100
Changelogging.
r11219@t0mlaptop (orig r11218):  rafl | 2009-08-23 12:55:48 +0100
Version 5.80011.
r11221@t0mlaptop (orig r11220):  rafl | 2009-08-23 19:42:17 +0100
Failing test for component loading
r11233@t0mlaptop (orig r11232):  t0m | 2009-08-24 13:51:03 +0100
Test fixes for if CATALYST_DEBUG is set to 1.
r11239@t0mlaptop (orig r11238):  t0m | 2009-08-25 12:25:54 +0100
0003-Remove-diag-message.patch (marcus)
r11240@t0mlaptop (orig r11239):  t0m | 2009-08-25 12:26:15 +0100
Fix duplicate components
r11252@t0mlaptop (orig r11251):  frew | 2009-08-26 20:00:01 +0100
Look!  I'm famous!  (See Catalyst-Devel)
r11254@t0mlaptop (orig r11253):  dandv | 2009-08-27 01:56:26 +0100
POD addition: $c->req->body returns a string or a File::Temp object
r11278@t0mlaptop (orig r11277):  t0m | 2009-09-01 02:07:23 +0100
Nuke skipped test which will never pass
r11279@t0mlaptop (orig r11278):  t0m | 2009-09-01 02:07:47 +0100
Author tests
r11280@t0mlaptop (orig r11279):  t0m | 2009-09-01 02:09:29 +0100
t/author in MANFEST
r11281@t0mlaptop (orig r11280):  t0m | 2009-09-01 02:10:46 +0100
Stop remote tests breaking everything, and force authors to run some remote tests.
r11282@t0mlaptop (orig r11281):  t0m | 2009-09-01 02:11:33 +0100
Stop calling class data methods on instances + commented out warning
r11283@t0mlaptop (orig r11282):  t0m | 2009-09-01 02:11:45 +0100
Changelog
r11300@t0mlaptop (orig r11292):  t0m | 2009-09-01 15:11:05 +0100
Bump versions back to 5.8.4
r11301@t0mlaptop (orig r11293):  t0m | 2009-09-01 15:32:46 +0100
Changes tweaks
r11307@t0mlaptop (orig r11299):  t0m | 2009-09-02 03:03:58 +0100
Changelogging
r11361@t0mlaptop (orig r11331):  t0m | 2009-09-07 15:45:01 +0100
Fix hash key name back to what it used to be for compat, keeping renamed accessor where it was. Tests for this breakage to follow
r11363@t0mlaptop (orig r11333):  t0m | 2009-09-07 21:19:40 +0100
Test for r11331 + fix to only report each action name once from get_action_methods
r11364@t0mlaptop (orig r11334):  t0m | 2009-09-07 21:21:52 +0100
I'm an idiot, that totally doesn't work. remove.
r11365@t0mlaptop (orig r11335):  t0m | 2009-09-07 21:25:53 +0100
AGH. Too tired to be doing this, fucked it up again
r11366@t0mlaptop (orig r11336):  t0m | 2009-09-07 21:33:31 +0100
Fix duplicate results from get_action_methods. Q. Why didn't I just do that first time round? A: Am idiot.

1  2 
lib/Catalyst/Controller.pm
t/lib/TestApp.pm

@@@ -2,7 -2,7 +2,7 @@@ package Catalyst::Controller
  
  use Moose;
  use Moose::Util qw/find_meta/;
+ use List::MoreUtils qw/uniq/;
  use namespace::clean -except => 'meta';
  
  BEGIN { extends qw/Catalyst::Component MooseX::MethodAttributes::Inheritable/; }
@@@ -29,9 -29,9 +29,9 @@@ has action_namespace =
       predicate => 'has_action_namespace',
      );
  
- has _controller_actions =>
+ has actions =>
      (
-      is => 'rw',
+      accessor => '_controller_actions',
       isa => 'HashRef',
       init_arg => undef,
      );
@@@ -44,6 -44,8 +44,8 @@@ sub BUILD 
      $self->_controller_actions($attr_value);
  }
  
  =head1 NAME
  
  Catalyst::Controller - Catalyst Controller base class
@@@ -135,28 -137,30 +137,30 @@@ around action_namespace => sub 
      my $orig = shift;
      my ( $self, $c ) = @_;
  
+     my $class = ref($self) || $self;
+     my $appclass = ref($c) || $c;
      if( ref($self) ){
          return $self->$orig if $self->has_action_namespace;
      } else {
-         return $self->config->{namespace} if exists $self->config->{namespace};
+         return $class->config->{namespace} if exists $class->config->{namespace};
      }
  
      my $case_s;
      if( $c ){
-         $case_s = $c->config->{case_sensitive};
+         $case_s = $appclass->config->{case_sensitive};
      } else {
          if ($self->isa('Catalyst')) {
-             $case_s = $self->config->{case_sensitive};
+             $case_s = $class->config->{case_sensitive};
          } else {
              if (ref $self) {
-                 $case_s = $self->_application->config->{case_sensitive};
+                 $case_s = ref($self->_application)->config->{case_sensitive};
              } else {
                  confess("Can't figure out case_sensitive setting");
              }
          }
      }
  
-     my $namespace = Catalyst::Utils::class2prefix($self->_component_name, $case_s) || '';
+     my $namespace = Catalyst::Utils::class2prefix($self->catalyst_component_name, $case_s) || '';
      $self->$orig($namespace) if ref($self);
      return $namespace;
  };
@@@ -177,8 -181,8 +181,8 @@@ around path_prefix => sub 
  
  sub get_action_methods {
      my $self = shift;
-     my $meta = find_meta($self);
-     confess("Metaclass for "
+     my $meta = find_meta($self) || confess("No metaclass setup for $self");
+     confess("Metaclass "
            . ref($meta) . " for "
            . $meta->name
            . " cannot support register_actions." )
                    . ( ref $self ) )
            } keys %{ $self->_controller_actions }
      ) if ( ref $self );
-     return @methods;
+     return uniq @methods;
  }
  
  
@@@ -207,17 -211,14 +211,17 @@@ sub register_actions 
  
  sub register_action_methods {
      my ( $self, $c, @methods ) = @_;
-     my $class = $self->_component_name;
+     my $class = $self->catalyst_component_name;
      #this is still not correct for some reason.
      my $namespace = $self->action_namespace($c);
  
 -    # Uncomment as soon as you fix the tests :)
 -    #if (!blessed($self) && $self eq $c && scalar(@methods)) {
 -    #    $c->log->warn("Action methods found defined in your application class, $self. This is deprecated, please move them into a Root controller.");
 -    #}
 +    # FIXME - fugly
 +    if (!blessed($self) && $self eq $c && scalar(@methods)) {
 +        my @really_bad_methods = grep { ! /^_(DISPATCH|BEGIN|AUTO|ACTION|END)$/ } map { $_->name } @methods;
 +        if (scalar(@really_bad_methods)) {
 +            $c->log->warn("Action methods (" . join(', ', @really_bad_methods) . ") found defined in your application class, $self. This is deprecated, please move them into a Root controller.");
 +        }
 +    }
  
      foreach my $method (@methods) {
          my $name = $method->name;
diff --combined t/lib/TestApp.pm
@@@ -41,6 -41,16 +41,6 @@@ sub count_leaks 
  
  TestApp->setup;
  
 -sub index : Private {
 -    my ( $self, $c ) = @_;
 -    $c->res->body('root index');
 -}
 -
 -sub global_action : Private {
 -    my ( $self, $c ) = @_;
 -    $c->forward('TestApp::View::Dump::Request');
 -}
 -
  sub execute {
      my $c      = shift;
      my $class  = ref( $c->component( $_[0] ) ) || $_[0];
@@@ -67,7 -77,7 +67,7 @@@
              @executed
          );
      }
+     no warnings 'recursion';
      return $c->SUPER::execute(@_);
  }
  
@@@ -82,6 -92,25 +82,6 @@@ sub finalize_error 
      $c->res->body( 'FATAL ERROR: ' . join( ', ', @{ $c->error } ) );
  }
  
 -sub class_forward_test_method :Private {
 -    my ( $self, $c ) = @_;
 -    $c->response->headers->header( 'X-Class-Forward-Test-Method' => 1 );
 -}
 -
 -sub loop_test : Local {
 -    my ( $self, $c ) = @_;
 -
 -    for( 1..1001 ) {
 -        $c->forward( 'class_forward_test_method' );
 -    }
 -}
 -
 -sub recursion_test : Local {
 -    my ( $self, $c ) = @_;
 -    no warnings 'recursion';
 -    $c->forward( 'recursion_test' );
 -}
 -
  {
      no warnings 'redefine';
      sub Catalyst::Log::error { }