[Catalyst-commits] r13195 - in
Catalyst-Runtime/5.80/branches/fix_request_uri: . lib
lib/Catalyst/DispatchType lib/Catalyst/Engine t/aggregate
t/lib t/lib/PluginTestApp/Controller t/lib/TestApp/Controller/Action
t0m at dev.catalyst.perl.org
t0m at dev.catalyst.perl.org
Sun May 2 23:32:02 GMT 2010
Author: t0m
Date: 2010-05-03 00:32:02 +0100 (Mon, 03 May 2010)
New Revision: 13195
Modified:
Catalyst-Runtime/5.80/branches/fix_request_uri/
Catalyst-Runtime/5.80/branches/fix_request_uri/Changes
Catalyst-Runtime/5.80/branches/fix_request_uri/Makefile.PL
Catalyst-Runtime/5.80/branches/fix_request_uri/lib/Catalyst.pm
Catalyst-Runtime/5.80/branches/fix_request_uri/lib/Catalyst/DispatchType/Regex.pm
Catalyst-Runtime/5.80/branches/fix_request_uri/lib/Catalyst/Engine/CGI.pm
Catalyst-Runtime/5.80/branches/fix_request_uri/t/aggregate/unit_core_engine_cgi-prepare_path.t
Catalyst-Runtime/5.80/branches/fix_request_uri/t/aggregate/unit_core_path_to.t
Catalyst-Runtime/5.80/branches/fix_request_uri/t/aggregate/unit_core_plugin.t
Catalyst-Runtime/5.80/branches/fix_request_uri/t/aggregate/unit_core_uri_for_action.t
Catalyst-Runtime/5.80/branches/fix_request_uri/t/lib/PluginTestApp.pm
Catalyst-Runtime/5.80/branches/fix_request_uri/t/lib/PluginTestApp/Controller/Root.pm
Catalyst-Runtime/5.80/branches/fix_request_uri/t/lib/TestApp/Controller/Action/Regexp.pm
Log:
r13213 at tomas-dorans-macbook-pro (orig r13177): ajgb | 2010-04-21 11:10:51 +0000
Fix not stripping backslashes in DispatchType::Regex::uri_for_action
r15483 at tomas-dorans-macbook-pro (orig r13190): rafl | 2010-04-28 22:54:04 +0000
Make sure path_to returns an instance of the right Path::Class class.
r15484 at tomas-dorans-macbook-pro (orig r13191): edenc | 2010-04-28 23:29:02 +0000
minor documentation fix for handle_request
r15489 at tomas-dorans-macbook-pro (orig r13193): rafl | 2010-05-02 23:16:25 +0000
Allow parameterized roles to be applied as plugins.
r15490 at tomas-dorans-macbook-pro (orig r13194): t0m | 2010-05-02 23:27:43 +0000
Back out crazy heuristics
Property changes on: Catalyst-Runtime/5.80/branches/fix_request_uri
___________________________________________________________________
Modified: svk:merge
- 1c72fc7c-9ce4-42af-bf25-3bfe470ff1e8:/local/Catalyst/trunk/Catalyst-Runtime:9763
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.70/branches/compres:7999
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.70/branches/context_go:8001
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.70/trunk:8533
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates:8363
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/add_captures_to_visit:9546
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/aggregate_more:11803
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/better_scripts:12074
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/disable_regex_fallback:11456
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/fix_path_info_decoding:12089
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/index_default_fuckage:10646
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/moose:7911
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/namespace_handling_refactor:10655
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/param_filtering:13012
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/uri_encode_captures_andor_args_take2:11811
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/uri_for_utf8:12834
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-ChildOf:4443
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-Runtime-jrockway:5857
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-component-setup:4320
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-docs:4325
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/current/Catalyst-Runtime:5142
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst:4483
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst-Runtime:6165
6d45476b-5895-46b8-b13a-8b969fa34c98:/local/Catalyst-Runtime-better_scripts:11331
8a9521aa-ff93-41d6-9f87-b05cafcdab40:/local/cat/Catalyst-Runtime/5.80/trunk:8157
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst/Catalyst-Runtime:8339
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst/Catalyst-Runtime-jrockway:8342
e56d974f-7718-0410-8b1c-b347a71765b2:/local/Catalyst-Runtime:6511
e56d974f-7718-0410-8b1c-b347a71765b2:/local/Catalyst-Runtime-current:10442
+ 1c72fc7c-9ce4-42af-bf25-3bfe470ff1e8:/local/Catalyst/trunk/Catalyst-Runtime:9763
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.70/branches/compres:7999
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.70/branches/context_go:8001
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.70/trunk:8533
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/Catalyst-Test-Updates:8363
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/add_captures_to_visit:9546
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/aggregate_more:11803
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/better_scripts:12074
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/disable_regex_fallback:11456
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/fix_path_info_decoding:12089
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/index_default_fuckage:10646
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/moose:7911
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/namespace_handling_refactor:10655
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/param_filtering:13012
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/uri_encode_captures_andor_args_take2:11811
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/branches/uri_for_utf8:12834
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.80/trunk:13194
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-ChildOf:4443
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-Runtime-jrockway:5857
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-component-setup:4320
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-docs:4325
4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/current/Catalyst-Runtime:5142
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst:4483
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst-Runtime:6165
6d45476b-5895-46b8-b13a-8b969fa34c98:/local/Catalyst-Runtime-better_scripts:11331
8a9521aa-ff93-41d6-9f87-b05cafcdab40:/local/cat/Catalyst-Runtime/5.80/trunk:8157
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst/Catalyst-Runtime:8339
d7608cd0-831c-0410-93c0-e5b306c3c028:/local/Catalyst/Catalyst-Runtime-jrockway:8342
e56d974f-7718-0410-8b1c-b347a71765b2:/local/Catalyst-Runtime:6511
e56d974f-7718-0410-8b1c-b347a71765b2:/local/Catalyst-Runtime-current:10442
Modified: Catalyst-Runtime/5.80/branches/fix_request_uri/Changes
===================================================================
--- Catalyst-Runtime/5.80/branches/fix_request_uri/Changes 2010-05-02 23:27:43 UTC (rev 13194)
+++ Catalyst-Runtime/5.80/branches/fix_request_uri/Changes 2010-05-02 23:32:02 UTC (rev 13195)
@@ -1,9 +1,6 @@
# This file documents the revision history for Perl extension Catalyst.
Bug fixes:
- - Additional fix for getting the base application path right when rewriting
- requests into an application sub path with mod_alias and mod_rewrite on
- Apache.
- Ensure to always cleanup temporary uploaded files in all cases, even
when exceptions occur during request processing, using HTTP::Body's
->cleanup feature. (RT#41442)
@@ -11,6 +8,7 @@
dereferencing it. (RT#49267)
- Fix regex special characters in REDIRECT_URL variable breaking
the request base. (2nd part of RT#24951)
+ - Fix not stripping backslashes in DispatchType::Regex::uri_for_action
New features:
- Setting __PACKAGE__->config(enable_catalyst_header => 1); in your MyApp.pm
@@ -19,6 +17,7 @@
HttpOnly flag
- Allow the myapp_test.pl script to be given a list of paths which it
will retrieve all of. (RT#53653)
+ - Allow parameterized roles to be applied as plugins.
Documentation:
- The Catalyst::Test::get method is documented as returning the raw
Modified: Catalyst-Runtime/5.80/branches/fix_request_uri/Makefile.PL
===================================================================
--- Catalyst-Runtime/5.80/branches/fix_request_uri/Makefile.PL 2010-05-02 23:27:43 UTC (rev 13194)
+++ Catalyst-Runtime/5.80/branches/fix_request_uri/Makefile.PL 2010-05-02 23:32:02 UTC (rev 13195)
@@ -26,6 +26,7 @@
requires 'Class::C3::Adopt::NEXT' => '0.07';
requires 'CGI::Simple::Cookie' => '1.109';
requires 'Data::Dump';
+requires 'Data::OptList';
requires 'HTML::Entities';
requires 'HTTP::Body' => '1.06'; # ->cleanup(1)
requires 'HTTP::Headers' => '1.64';
Modified: Catalyst-Runtime/5.80/branches/fix_request_uri/lib/Catalyst/DispatchType/Regex.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/fix_request_uri/lib/Catalyst/DispatchType/Regex.pm 2010-05-02 23:27:43 UTC (rev 13194)
+++ Catalyst-Runtime/5.80/branches/fix_request_uri/lib/Catalyst/DispatchType/Regex.pm 2010-05-02 23:32:02 UTC (rev 13195)
@@ -151,6 +151,7 @@
my $re = "$orig";
$re =~ s/^\^//;
$re =~ s/\$$//;
+ $re =~ s/\\([^\\])/$1/g;
my $final = '/';
my @captures = @$captures;
while (my ($front, $rest) = split(/\(/, $re, 2)) {
Modified: Catalyst-Runtime/5.80/branches/fix_request_uri/lib/Catalyst/Engine/CGI.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/fix_request_uri/lib/Catalyst/Engine/CGI.pm 2010-05-02 23:27:43 UTC (rev 13194)
+++ Catalyst-Runtime/5.80/branches/fix_request_uri/lib/Catalyst/Engine/CGI.pm 2010-05-02 23:32:02 UTC (rev 13195)
@@ -158,16 +158,20 @@
if (my $req_uri = $ENV{REQUEST_URI}) {
$req_uri =~ s/^\Q$base_path\E//;
$req_uri =~ s/\?.*$//;
- if ($req_uri && $req_uri ne '/') {
+ if ($req_uri) {
+ # Note that if REQUEST_URI doesn't start with a /, then the user
+ # is probably using mod_rewrite or something to rewrite requests
+ # into a sub-path of their application..
# This means that REQUEST_URI needs information from PATH_INFO
# prepending to it to be useful, otherwise the sub path which is
# being redirected to becomes the app base address which is
# incorrect.
- # FIXME - This stuff is shit, we should get REDIRECT_URI, right?
- my ($match) = $req_uri =~ m{^(/?[^/]+)};
- my ($path_info_part) = $path_info =~ m|^(.*?\Q$match\E)|;
- substr($req_uri, 0, length($match), $path_info_part)
- if $path_info_part;
+ if (substr($req_uri, 0, 1) ne '/') {
+ my ($match) = $req_uri =~ m|^([^/]+)|;
+ my ($path_info_part) = $path_info =~ m|^(.*?\Q$match\E)|;
+ substr($req_uri, 0, length($match), $path_info_part)
+ if $path_info_part;
+ }
$path_info = $req_uri;
}
}
Modified: Catalyst-Runtime/5.80/branches/fix_request_uri/lib/Catalyst.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/fix_request_uri/lib/Catalyst.pm 2010-05-02 23:27:43 UTC (rev 13194)
+++ Catalyst-Runtime/5.80/branches/fix_request_uri/lib/Catalyst.pm 2010-05-02 23:32:02 UTC (rev 13195)
@@ -14,6 +14,7 @@
use Catalyst::Response;
use Catalyst::Utils;
use Catalyst::Controller;
+use Data::OptList;
use Devel::InnerPackage ();
use File::stat;
use Module::Pluggable::Object ();
@@ -2782,6 +2783,7 @@
my ( $proto, $plugin, $instant ) = @_;
my $class = ref $proto || $proto;
+ # FIXME: also pass along plugin options as soon as the mop has it
Class::MOP::load_class( $plugin );
$class->log->warn( "$plugin inherits from 'Catalyst::Component' - this is decated and will not work in 5.81" )
if $plugin->isa( 'Catalyst::Component' );
@@ -2797,22 +2799,30 @@
my ( $class, $plugins ) = @_;
$class->_plugins( {} ) unless $class->_plugins;
- $plugins ||= [];
+ $plugins = Data::OptList::mkopt($plugins || []);
- my @plugins = Catalyst::Utils::resolve_namespace($class . '::Plugin', 'Catalyst::Plugin', @$plugins);
+ my @plugins = map {
+ [ Catalyst::Utils::resolve_namespace(
+ $class . '::Plugin',
+ 'Catalyst::Plugin', $_->[0]
+ ),
+ $_->[1],
+ ]
+ } @{ $plugins };
for my $plugin ( reverse @plugins ) {
- Class::MOP::load_class($plugin);
- my $meta = find_meta($plugin);
+ Class::MOP::load_class($plugin->[0]);
+ # pass along $plugin->[1] as well once cmop supports it
+ my $meta = find_meta($plugin->[0]);
next if $meta && $meta->isa('Moose::Meta::Role');
- $class->_register_plugin($plugin);
+ $class->_register_plugin($plugin->[0]);
}
my @roles =
- map { $_->name }
- grep { $_ && blessed($_) && $_->isa('Moose::Meta::Role') }
- map { find_meta($_) }
+ map { $_->[0]->name, $_->[1] }
+ grep { $_->[0] && blessed($_->[0]) && $_->[0]->isa('Moose::Meta::Role') }
+ map { [find_meta($_->[0]), $_->[1]] }
@plugins;
Moose::Util::apply_all_roles(
Modified: Catalyst-Runtime/5.80/branches/fix_request_uri/t/aggregate/unit_core_engine_cgi-prepare_path.t
===================================================================
--- Catalyst-Runtime/5.80/branches/fix_request_uri/t/aggregate/unit_core_engine_cgi-prepare_path.t 2010-05-02 23:27:43 UTC (rev 13194)
+++ Catalyst-Runtime/5.80/branches/fix_request_uri/t/aggregate/unit_core_engine_cgi-prepare_path.t 2010-05-02 23:32:02 UTC (rev 13195)
@@ -87,6 +87,7 @@
}
{
+ local $TODO = 'Another mod_rewrite case';
my $r = get_req (
PATH_INFO => '/auth/login',
SCRIPT_NAME => '/tx',
Modified: Catalyst-Runtime/5.80/branches/fix_request_uri/t/aggregate/unit_core_path_to.t
===================================================================
--- Catalyst-Runtime/5.80/branches/fix_request_uri/t/aggregate/unit_core_path_to.t 2010-05-02 23:27:43 UTC (rev 13194)
+++ Catalyst-Runtime/5.80/branches/fix_request_uri/t/aggregate/unit_core_path_to.t 2010-05-02 23:32:02 UTC (rev 13195)
@@ -2,6 +2,9 @@
use warnings;
use Test::More;
+use FindBin;
+use Path::Class;
+use File::Basename;
my %non_unix = (
MacOS => 1,
@@ -16,17 +19,20 @@
my $os = $non_unix{$^O} ? $^O : 'Unix';
-if( $os ne 'Unix' ) {
+if ( $os ne 'Unix' ) {
plan skip_all => 'tests require Unix';
}
-else {
- plan tests => 3;
-}
use_ok('Catalyst');
my $context = 'Catalyst';
+$context->setup_home;
+my $base = dir($FindBin::Bin)->relative->stringify;
+
+isa_ok( Catalyst::path_to( $context, $base ), 'Path::Class::Dir' );
+isa_ok( Catalyst::path_to( $context, $base, basename $0 ), 'Path::Class::File' );
+
my $config = Catalyst->config;
$config->{home} = '/home/sri/my-app/';
@@ -37,3 +43,5 @@
is( Catalyst::path_to( $context, 'foo', 'bar' ),
'/Users/sri/myapp/foo/bar', 'deep Unix path' );
+
+done_testing;
Modified: Catalyst-Runtime/5.80/branches/fix_request_uri/t/aggregate/unit_core_plugin.t
===================================================================
--- Catalyst-Runtime/5.80/branches/fix_request_uri/t/aggregate/unit_core_plugin.t 2010-05-02 23:27:43 UTC (rev 13194)
+++ Catalyst-Runtime/5.80/branches/fix_request_uri/t/aggregate/unit_core_plugin.t 2010-05-02 23:32:02 UTC (rev 13195)
@@ -3,7 +3,7 @@
use strict;
use warnings;
-use Test::More tests => 24;
+use Test::More;
use lib 't/lib';
@@ -61,3 +61,4 @@
is_deeply [ TestApp->registered_plugins ], \@expected,
'registered_plugins() should only report the plugins for the current class';
+done_testing;
Modified: Catalyst-Runtime/5.80/branches/fix_request_uri/t/aggregate/unit_core_uri_for_action.t
===================================================================
--- Catalyst-Runtime/5.80/branches/fix_request_uri/t/aggregate/unit_core_uri_for_action.t 2010-05-02 23:27:43 UTC (rev 13194)
+++ Catalyst-Runtime/5.80/branches/fix_request_uri/t/aggregate/unit_core_uri_for_action.t 2010-05-02 23:32:02 UTC (rev 13195)
@@ -8,7 +8,7 @@
use Test::More;
-plan tests => 30;
+plan tests => 33;
use_ok('TestApp');
@@ -54,6 +54,21 @@
"/action/regexp/foo/123",
"Regex action interpolates captures correctly");
+my $regex_action_bs = $dispatcher->get_action_by_path(
+ '/action/regexp/one_backslashes'
+ );
+
+ok(!defined($dispatcher->uri_for_action($regex_action_bs)),
+ "Regex action without captures returns undef");
+
+ok(!defined($dispatcher->uri_for_action($regex_action_bs, [ 1, 2, 3 ])),
+ "Regex action with too many captures returns undef");
+
+is($dispatcher->uri_for_action($regex_action_bs, [ 'foo', 123 ]),
+ "/action/regexp/foo/123.html",
+ "Regex action interpolates captures correctly");
+
+
#
# Index Action
#
Modified: Catalyst-Runtime/5.80/branches/fix_request_uri/t/lib/PluginTestApp/Controller/Root.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/fix_request_uri/t/lib/PluginTestApp/Controller/Root.pm 2010-05-02 23:27:43 UTC (rev 13194)
+++ Catalyst-Runtime/5.80/branches/fix_request_uri/t/lib/PluginTestApp/Controller/Root.pm 2010-05-02 23:32:02 UTC (rev 13195)
@@ -34,6 +34,13 @@
ref($c)->plugin( faux => $faux_plugin );
isa_ok $c, 'Catalyst::Plugin::Test::Plugin';
+
+ # applied parameterized role
+ if (eval { require MooseX::Role::Parameterized; 1 }) {
+ can_ok $c, 'affe';
+ is $c->affe, 'birne', 'right method created by parameterized role';
+ }
+
isa_ok $c, 'TestApp::Plugin::FullyQualified';
ok !$c->isa($faux_plugin),
'... and it should not inherit from the instant plugin';
Modified: Catalyst-Runtime/5.80/branches/fix_request_uri/t/lib/PluginTestApp.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/fix_request_uri/t/lib/PluginTestApp.pm 2010-05-02 23:27:43 UTC (rev 13194)
+++ Catalyst-Runtime/5.80/branches/fix_request_uri/t/lib/PluginTestApp.pm 2010-05-02 23:32:02 UTC (rev 13195)
@@ -1,10 +1,13 @@
package PluginTestApp;
use Test::More;
-use Catalyst qw(
- Test::Plugin
- +TestApp::Plugin::FullyQualified
- );
+use Catalyst (
+ 'Test::Plugin',
+ '+TestApp::Plugin::FullyQualified',
+ (eval { require MooseX::Role::Parameterized; 1 }
+ ? ('+TestApp::Plugin::ParameterizedRole' => { method_name => 'affe' })
+ : ()),
+);
sub _test_plugins {
my $c = shift;
Modified: Catalyst-Runtime/5.80/branches/fix_request_uri/t/lib/TestApp/Controller/Action/Regexp.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/fix_request_uri/t/lib/TestApp/Controller/Action/Regexp.pm 2010-05-02 23:27:43 UTC (rev 13194)
+++ Catalyst-Runtime/5.80/branches/fix_request_uri/t/lib/TestApp/Controller/Action/Regexp.pm 2010-05-02 23:32:02 UTC (rev 13195)
@@ -27,4 +27,9 @@
);
}
+sub one_backslashes : Action Regex('^action/regexp/(\w+)/(\d+)\.html$') {
+ my ( $self, $c ) = @_;
+ $c->forward('TestApp::View::Dump::Request');
+}
+
1;
More information about the Catalyst-commits
mailing list