updated changes
John Napiorkowski [Mon, 18 Mar 2013 20:40:00 +0000 (16:40 -0400)]
1  2 
Changes
lib/Catalyst/DispatchType/Chained.pm

diff --combined Changes
+++ b/Changes
  # This file documents the revision history for Perl extension Catalyst.
  
 +5.90021 - TBA
++  - documentation updates around forwarding to chained actions
 +  - Fixed bug when a PSGI engine need to use psgix logger
 +  - Added cpanfile as a way to notice we are a dev checkout
 +  - Added 'x-tunneled-method' HTTP Header method override to match features in
 +    Catalyst::Action::REST and in other similar systems on CPAN
 +
 +5.90020 - 2013-02-22
 +  ! Catalyst::Action now defines 'match_captures' so it is no long considered
 +    an optional method.  This might break you code if you have made custom
 +    action roles/classes where you define 'match_captures'.  You must change
 +    your code to use a method modifier (such as 'around').
 +  - New match method "Method($HTTP_METHOD)" where $HTTP_METHOD in (GET, POST,
 +    PUT, HEAD, DELETE, OPTION) and shortcuts in controllers called "GET, POST
 +    PUT, HEAD, DELETE, OPTION").  Tests and documentation.  Please note if you
 +    are currently using Catalyst::ActionRole::MatchRequestMethods there may
 +    be compatibility issues.  You should remove that actionrole since the built
 +    in behavior is compatible on its own.
 +  - Initial debug screen now shows HTTP Method Match info
 +  - security fixes in the way we handle redirects
 +  - Make Catalyst::Engine and Catalyst::Base immutable
 +  - Some test and documentation improvements
 +
 +5.90019 - 2012-12-04 21:31:00
 +  - Fix for perl 5.17.6 (commit g7dc8663). RT#81601
 +  - Fix for perl 5.8. RT#61122
 +  - Remove use of MooseX::Types as MooseX::Types is broken on perl5.8
 +    RT#77100 & RT#81121
 +
 +5.90018 - 2012-10-23 20:55:00
 +  - Changed code in test suite so it no longer trips up on recent changes to
 +    HTTP::Message.
 +
 +5.90017 - 2012-10-19 22:33:00
 +  - Change Catalyst _parse_attrs so that when sub attr handlers:
 +
 +    1) Can return multiple pairs of new attributes.
 +    2) Get their returned attributes passed through the correct attribute handler.
 +
 +    e.g sub _parse_Whatever_attr { return Chained => 'foo', PathPart => 'bar' }
 +
 +    Will now work because both new attributes are respected, and the Chained
 +    attribute is passed to _parse_Chained_attr and fixed up correctly by that.
 +
 +  - In Catalyst::Test, don't mangle headers of non-HTML responses. RT#79043
 +
 +  - Refactor request and response class construction to add methods
 +    that roles can hook to feed extra parameters into the constructor
 +    of request or response classes.
 +
 +5.90016 - 2012-08-16 15:35:00
 +  - prepare_parameters is no longer an attribute builder.  It is now a method
 +    that calls the correct underlying functionality (Bill Moseley++)
 +  - Updated Makefile.PL to handle MacOXS tar
 +  - Fix uri_for to handle a stringifiable object
 +  - Fix model/view/controller methods to handle stringifiable objects
 +  - Fix RT#78377 - IIS7 ignores response body for 3xx requests, which
 +    causes (a different) response to be broken when using keepalive.
 +    Fixed by applying Middleware which removes the response body and
 +    content length that Catalyst supplies with redirects.
 +
 +5.90015 - 2012-06-30 16:57:00
 +  - Fix $c->finalize_headers getting called twice. RT#78090
 +  - Fix test fails in Catalyst-Plugin-Session-State-Cookie. RT#76179
 +  - Fix test fails in Catalyst-Plugin-StackTrace
 +  - Fix test fails in Test-WWW-Mechanize-Catalyst
 +
 +5.90014 - 2012-06-26 10:00:00
 +
 +  - Fix calling finalize_headers before writing body when using $c->write /
 +    $c->res->write (fixes RT#76179).
 +
 +5.90013 - 2012-06-21 10:40:00
 +
 +  - Release previous TRIAL as stable.
 +  - We failed to note in the previous changelog that the Makefile.PL has been
 +    improved to make it easier for authors to bootstrap a developer install
 +    of Catalyst.
 +
 +5.90013 - TRIAL 2012-06-07 20:21:00
 +
 + New features:
 +  - Merge Catalyst::Controller::ActionRole into Catalyst::Controller.
 +
 + Bug fixes:
 +  - Fix warnings in some matching cases for Action methods with
 +    Args(), when using Catalyst::DispatchType::Chained
 +
 +  - Fix request body parameters to not be undef if no parameters
 +    are supplied.
 +
 +  - Fix action_args config so that it can be specified in the
 +    top level config.
 +
 +  - Fix t/author/http-server.t on Win32
 +
 +  - Fix use of Test::Aggregate to make tests faster.
 +
 +5.90012 - 2012-05-16 09:59:00
 +
 + Distribution META.yml changes:
 +  - author key is now correct, rather than what Module::Install
 +    mis-parses from the documentation.
 +  - x_authority key added.
 +
 + Bug fixes:
 +  - Fix request body parameters being multiply rebuilt. Fixes both
 +    RT#75607 and CatalystX::DebugFilter
 +
 +  - Make plugin de-duplication work as intended originally, as whilst
 +    duplicate plugins are totally unwise, the C3 error given to the user
 +    is less than helpful.
 +
 +  - Remove dependence on obscure behaviour in B::Hooks::EndOfScope
 +    for backward compatibility. This fixes issues with behaviour changes
 +    in bleadperl. RT#76437
 +
 +  - Work around Moose bug RT#75367 which breaks
 +    Catalyst::Controller::DBIC::API.
 +
 + Documentation:
 +  - Fix documentation in Catalyst::Component to show attributes and
 +    calling readers, rather than accessing elements in the $self->{} hash
 +    directly.
 +  - Add note in Catalyst::Component to strongly disrecommend $self->config
 +  - Fix vague 'checkout' wording in Catalyst::Utils. RT#77000
 +  - Fix documentation for the 'secure' method in Catalyst:Request. RT#76710
 +
 +5.90011 - 2012-03-08 16:43:00
 +
 + Bug fixes:
 +  - Simplification of the previous changes to Catalyst::ScriptRunner
 +    We now just push $FindBin::Bin/../lib to the @INC path again, but
 +    only if one of the dist indicator files (Makefile.PL Build.PL or
 +    dist.ini) can be found in $FindBin::Bin/../$_
 +    This avoids heuristics when the app is unloaded and therefore
 +    works better for extensions which have entire applications in
 +    their test suites.
 +  - Bug fix to again correctly detect checkouts in dist zilla using
 +    applications.
 +  - --background option for the server script now only closes
 +    STDIN, STDOUT and STDERR. This fixes issues with Log::Dispatch
 +    and other loggers which open a file handle when
 +  - Change incorrect use of File::Spec->catdir to File::Spec->catfile
 +    so that we work on platforms which care about this (VMS?)
 +  - Make it more obvious if our PSGI server doesn't pass in a response
 +    callback.
 +
 +5.90010 - 2012-02-18 00:01:00
 +
 + Bug fixes:
 +  - Fix the previous fix to Catalyst::ScriptRunner which was resulting
 +    in the lib directory not being pushed onto @INC.
 +    This meant perl ./script/myapp_server.pl failed, however
 +    perl -Ilib ./script/myapp_server.pl would succeed.
 +
 +5.90009 - 2012-02-16 09:06:00
 +
 + Bug fixes:
 +  - Fix the debug page so that it works as expected with the latest
 +    refactoring.
 +
 +  - The Catalyst::Utils::home function is used to find if the application
 +    is a checkout in Catalyst::ScriptRunner. This means that a non-existant
 +    lib directory that is relative to the script install location is not
 +    included when not running from a checkout.
 +
 +  - Fix dead links to cpansearch.perl.org to point to metacpan.org.
 +
 +  - Require the latest version of B::Hooks::EndOfScope (0.10) to avoid an
 +    issue with new versions of Module::Runtime (0.012) on perl 5.10
 +    which stopped Catalyst::Controller from compiling.
 +
 +  - In Catalyst::Test, don't mangle headers of non-HTML responses. RT#79043
 +
 +5.90008 - TRIAL 2012-02-06 20:49:00
 +
 + New features and refactoring:
 +  - Much of the Catalyst::Engine code has been moved into Catalyst::Request
 +    and Catalyst::Response, to be able to better support asynchronous web
 +    servers such as Twiggy, by making the application engine more reenterant.
 +
 +    This change is as a prequel to full asynchronous support inside Catalyst
 +    for AnyEvent and IO::Async backends, which allow highly scaleable streaming
 +    (for applications such as multi-part XML HTTPRequests, and Websockets).
 +
 + Deprecations:
 +  - This means that the $c->engine->env method to access the PSGI environment
 +    is now deprecated. The accessor for the PSGI env is now on Catalyst::Request
 +    as per applications which were using Catalyst::Engine::PSGI
 +
 +    Catalyst::Engine::PSGI is now considered fully deprecated.
 +
 +  - The private _dump method in Catalyst::Log is now deprecated. The dumper is
 +    not pluggable and which dumper to use should be a user choice. Using
 +    an imported Dump() or Dumper() function is less typing than $c->log->_dump
 +    and as this method is unused anywhere else in Catalyst, it has been scheduled
 +    for removal as a cleanup. Calling this method will now emit a stack trace
 +    on first call (but not on subsequent calls).
 +
 + Back compatibility fixes:
 +  - Applications still using Catalyst::Engine::PSGI as they rely on
 +    $c->request->env - this is now the provided (and recommended) way of
 +    accessing the raw PSGI environment.
 +
 + Tests:
 +  - Spurious warnings have been removed from the test suite
 +
 + Documentation:
 +  - Fix the display of PROJECT FOUNDER and CONTRIBUTORS sections in the
 +    documentation. These were erroneously being emitted when the Pod
 +    was converted to HTML for search.cpan.org
 +
 +  - Fix documentation for the build_psgi_app app method. Previously the
 +    documentation advised that it provided the psgi app already wrapped
 +    in default middleware. This is not the case - it is the raw app psgi
 +
 +5.90007 - 2011-11-22 20:35:00
 +
 +  New features:
 +   - Implement a match_captures hook which, if it exists on an action,
 +     is called with the $ctx and \@captures and is expected to return
 +     true to continue the chain matching and false to stop matching.
 +     This can be used to implement action classes or roles which match
 +     conditionally (for example only matching captures which are integers).
 +
    Bug fixes:
     - Lighttpd script name fix is only applied for lighttpd versions
 -     < 1.4.23
 +     < 1.4.23. This should fix non-root installs of lighttpd in versions
 +     over that.
     - Prepare_action is now inside a try {} block, so that requests containing
       bad unicode can be appropriately trapped by
       Catalyst::Plugin::Unicode::Encoding
@@@ -96,15 -96,14 +96,15 @@@ sub list 
                    sort { $a->reverse cmp $b->reverse }
                             @{ $self->_endpoints }
                    ) {
 -        my $args = $endpoint->attributes->{Args}->[0];
 +        my $args = $endpoint->list_extra_info->{Args};
          my @parts = (defined($args) ? (("*") x $args) : '...');
          my @parents = ();
          my $parent = "DUMMY";
 +        my $extra  = $self->_list_extra_http_methods($endpoint);
          my $curr = $endpoint;
          while ($curr) {
 -            if (my $cap = $curr->attributes->{CaptureArgs}) {
 -                unshift(@parts, (("*") x $cap->[0]));
 +            if (my $cap = $curr->list_extra_info->{CaptureArgs}) {
 +                unshift(@parts, (("*") x $cap));
              }
              if (my $pp = $curr->attributes->{PathPart}) {
                  unshift(@parts, $pp->[0])
          my @rows;
          foreach my $p (@parents) {
              my $name = "/${p}";
 -            if (my $cap = $p->attributes->{CaptureArgs}) {
 -                $name .= ' ('.$cap->[0].')';
 +
 +            if (defined(my $extra = $self->_list_extra_http_methods($p))) {
 +                $name = "${extra} ${name}";
 +            }
 +            if (defined(my $cap = $p->list_extra_info->{CaptureArgs})) {
 +                $name .= ' ('.$cap.')';
              }
              unless ($p eq $parents[0]) {
                  $name = "-> ${name}";
              }
              push(@rows, [ '', $name ]);
          }
 -        push(@rows, [ '', (@rows ? "=> " : '')."/${endpoint}" ]);
 +        push(@rows, [ '', (@rows ? "=> " : '').($extra ? "$extra " : '')."/${endpoint}" ]);
          $rows[0][0] = join('/', '', @parts) || '/';
          $paths->row(@$_) for @rows;
      }
          if $has_unattached_actions;
  }
  
 +sub _list_extra_http_methods {
 +    my ( $self, $action ) = @_;
 +    return unless defined $action->list_extra_info->{HTTP_METHODS};
 +    return join(', ', @{$action->list_extra_info->{HTTP_METHODS}});
 +}
 +
  =head2 $self->match( $c, $path )
  
  Calls C<recurse_match> to see if a chain matches the C<$path>.
@@@ -212,10 -201,9 +212,10 @@@ sub recurse_match 
          my @try_actions = @{$children->{$try_part}};
          TRY_ACTION: foreach my $action (@try_actions) {
              if (my $capture_attr = $action->attributes->{CaptureArgs}) {
 +                $capture_attr ||= 0;
  
                  # Short-circuit if not enough remaining parts
 -                next TRY_ACTION unless @parts >= ($capture_attr->[0]||0);
 +                next TRY_ACTION unless @parts >= $capture_attr->[0];
  
                  my @captures;
                  my @parts = @parts; # localise
                  # strip CaptureArgs into list
                  push(@captures, splice(@parts, 0, $capture_attr->[0]));
  
 +                # check if the action may fit, depending on a given test by the app
 +                if ($action->can('match_captures')) { next TRY_ACTION unless $action->match_captures($c, \@captures) }
 +
                  # try the remaining parts against children of this action
                  my ($actions, $captures, $action_parts, $n_pathparts) = $self->recurse_match(
                                               $c, '/'.$action->reverse, \@parts
  
                  if (!$best_action                       ||
                      @parts < @{$best_action->{parts}}   ||
 -                    (!@parts && $args_attr eq 0)){
 +                    (!@parts && defined($args_attr) && $args_attr eq "0")){
                      $best_action = {
                          actions => [ $action ],
                          captures=> [],
@@@ -372,7 -357,7 +372,7 @@@ sub uri_for_action 
      my $curr = $action;
      while ($curr) {
          if (my $cap = $curr->attributes->{CaptureArgs}) {
 -            return undef unless @captures >= $cap->[0]; # not enough captures
 +            return undef unless @captures >= ($cap->[0]||0); # not enough captures
              if ($cap->[0]) {
                  unshift(@parts, splice(@captures, -$cap->[0]));
              }
@@@ -685,17 -670,12 +685,19 @@@ of the endpoint of the chain, not on th
  C<auto> actions will be run before the chain dispatching begins. In
  every other aspect, C<auto> actions behave as documented.
  
- The C<forward>ing to other actions does just what you would expect. But if
- you C<detach> out of a chain, the rest of the chain will not get called
- after the C<detach>.
+ The C<forward>ing to other actions does just what you would expect. ie
+ only the target action is run. The actions that that action is chained
+ to are not run.
+ If you C<detach> out of a chain, the rest of the chain will not get
+ called after the C<detach>.
  
 +=head2 match_captures
 +
 +A method which can optionally be implemented by actions to
 +stop chain matching.
 +
 +See L<Catalyst::Action> for further details.
 +
  =head1 AUTHORS
  
  Catalyst Contributors, see Catalyst.pm