[Catalyst-commits] r7474 - in Catalyst-Runtime/5.80/trunk: . lib
lib/Catalyst lib/Catalyst/Engine t
matthewt at dev.catalyst.perl.org
matthewt at dev.catalyst.perl.org
Mon Mar 10 20:26:05 GMT 2008
Author: matthewt
Date: 2008-03-10 20:26:05 +0000 (Mon, 10 Mar 2008)
New Revision: 7474
Added:
Catalyst-Runtime/5.80/trunk/t/unit_core_uri_for_multibytechar.t
Modified:
Catalyst-Runtime/5.80/trunk/
Catalyst-Runtime/5.80/trunk/Changes
Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm
Catalyst-Runtime/5.80/trunk/lib/Catalyst/Action.pm
Catalyst-Runtime/5.80/trunk/lib/Catalyst/Component.pm
Catalyst-Runtime/5.80/trunk/lib/Catalyst/Controller.pm
Catalyst-Runtime/5.80/trunk/lib/Catalyst/Engine/HTTP.pm
Catalyst-Runtime/5.80/trunk/lib/Catalyst/Request.pm
Catalyst-Runtime/5.80/trunk/lib/Catalyst/Utils.pm
Catalyst-Runtime/5.80/trunk/t/unit_controller_config.t
Catalyst-Runtime/5.80/trunk/t/unit_utils_load_class.t
Log:
r16513 at agaton (orig r7161): matthewt | 2007-11-26 17:16:50 +0000
fix __PACKAGE__->config->{foo} = 'bar' for subclassing
r16625 at agaton (orig r7273): andyg | 2007-12-11 14:17:58 +0000
Fixed a bug where -rr (restart regex) command line option could cause shell errors
r16703 at agaton (orig r7351): marcus | 2008-01-04 22:26:51 +0000
changes, pod fix
r16735 at agaton (orig r7383): jrockway | 2008-01-13 22:07:03 +0000
add a comment explaining why we use bytes
r16736 at agaton (orig r7384): jrockway | 2008-01-13 22:45:35 +0000
encode unicode to utf8 by default (in finalize)
r16737 at agaton (orig r7385): jrockway | 2008-01-14 00:12:29 +0000
remove the "useless localization of subroutine entry" warning by removing the useless localization of subroutine entry
r16738 at agaton (orig r7386): jrockway | 2008-01-14 00:14:12 +0000
Revert "encode unicode to utf8 by default (in finalize)". I need
to add some tests before checking this in.
This reverts commit fb951a66d9ce0be22705975f89278b99697331cd.
r16744 at agaton (orig r7392): bricas | 2008-01-16 12:36:28 +0000
fix uri_for()'s handling of multibyte chars (Daisuke Murase)
r16752 at agaton (orig r7400): bricas | 2008-01-17 12:59:07 +0000
apply uri_with() patch from Daisuke Murase
r16822 at agaton (orig r7429): castaway | 2008-02-02 15:32:22 +0000
Steal class loading code from Class::MOP, which isnt confused by __PACKAGE__
r17246 at agaton (orig r7439): gphat | 2008-02-11 16:32:21 +0000
Note the detructiveness of uri_for when used with hashrefs.
r17247 at agaton (orig r7440): jrockway | 2008-02-12 07:55:11 +0000
fix up the unit_core_uri_for_multibytechar test; "use utf8" so that we actually test the submitted code (instead of nothing)
r17249 at agaton (orig r7442): miyagawa | 2008-02-17 11:51:40 +0000
reverted r7440 since what Daisuke meant to test was utf-8 bytes, not
unicode strings. "use utf8" will turn all literals to Unicode string,
which is not what we want to test against uri_for here.
Property changes on: Catalyst-Runtime/5.80/trunk
___________________________________________________________________
Name: svk:merge
- 1c72fc7c-9ce4-42af-bf25-3bfe470ff1e8:/local/Catalyst/trunk/Catalyst-Runtime:9763
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Runtime/5.70/trunk:7103
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
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/trunk:7442
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
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/trunk/Changes
===================================================================
--- Catalyst-Runtime/5.80/trunk/Changes 2008-03-09 19:00:47 UTC (rev 7473)
+++ Catalyst-Runtime/5.80/trunk/Changes 2008-03-10 20:26:05 UTC (rev 7474)
@@ -1,9 +1,14 @@
# This file documents the revision history for Perl extension Catalyst.
-5.7012
+5.7012 2007-12-16 23:44:00
+ - Fix uri_for()'s and uri_with()'s handling of multibyte chars
+ (Daisuke Murase)
+ - Fix __PACKAGE__->config->{foo} = 'bar' case with subclassing
- Add Catalyst::Stats (Jon Schutz)
- Fixed a bug where ?q=bar=baz is decoded as q=>'bar', not 'bar=baz'.
(Tatsuhiko Miyagawa, Masahiro Nagano)
+ - Fixed a bug where -rr (restart regex) command line option could cause
+ shell errors. (Aristotle Pagaltzis, Chisel Wright)
5.7011 2007-10-18 20:40:00
- Allow multiple restart directories and added option to follow
Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst/Action.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst/Action.pm 2008-03-09 19:00:47 UTC (rev 7473)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst/Action.pm 2008-03-10 20:26:05 UTC (rev 7474)
@@ -38,7 +38,7 @@
sub dispatch { # Execute ourselves against a context
my ( $self, $c ) = @_;
- local $c->namespace = $self->namespace;
+ local $c->{namespace} = $self->namespace;
return $c->execute( $self->class, $self );
}
Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst/Component.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst/Component.pm 2008-03-09 19:00:47 UTC (rev 7473)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst/Component.pm 2008-03-10 20:26:05 UTC (rev 7474)
@@ -87,15 +87,29 @@
sub config {
my $self = shift;
- my $config = $self->_config;
- unless ($config) {
- $self->_config( $config = {} );
- }
+ my $config_sub = $self->can('_config');
+ my $config = $self->$config_sub() || {};
if (@_) {
my $newconfig = { %{@_ > 1 ? {@_} : $_[0]} };
$self->_config(
$self->merge_config_hashes( $config, $newconfig )
);
+ } else {
+ # this is a bit of a kludge, required to make
+ # __PACKAGE__->config->{foo} = 'bar';
+ # work in a subclass. Calling the Class::Data::Inheritable setter
+ # will create a new _config method in the current class if it's
+ # currently inherited from the superclass. So, the can() call will
+ # return a different subref in that case and that means we know to
+ # copy and reset the value stored in the class data.
+
+ $self->_config( $config );
+
+ if ((my $config_sub_now = $self->can('_config')) ne $config_sub) {
+
+ $config = $self->merge_config_hashes( $config, {} );
+ $self->$config_sub_now( $config );
+ }
}
return $config;
}
Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst/Controller.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst/Controller.pm 2008-03-09 19:00:47 UTC (rev 7473)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst/Controller.pm 2008-03-10 20:26:05 UTC (rev 7474)
@@ -310,7 +310,7 @@
will be bound to 'foo/bar'. The default Root controller is an example
of setting namespace to '' (the null string).
-=head2 prefix
+=head2 path
Sets 'path_prefix', as described below.
Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst/Engine/HTTP.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst/Engine/HTTP.pm 2008-03-09 19:00:47 UTC (rev 7473)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst/Engine/HTTP.pm 2008-03-10 20:26:05 UTC (rev 7474)
@@ -333,7 +333,7 @@
use Config;
$ENV{PERL5LIB} .= join $Config{path_sep}, @INC;
- exec $^X . ' "' . $0 . '" ' . join( ' ', @{ $options->{argv} } );
+ exec $^X, $0, @{ $options->{argv} };
}
exit;
Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst/Request.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst/Request.pm 2008-03-09 19:00:47 UTC (rev 7473)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst/Request.pm 2008-03-10 20:26:05 UTC (rev 7474)
@@ -539,7 +539,7 @@
next unless defined $value;
for ( ref $value eq 'ARRAY' ? @$value : $value ) {
$_ = "$_";
- utf8::encode( $_ );
+ utf8::encode( $_ ) if utf8::is_utf8($_);
}
};
Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst/Utils.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst/Utils.pm 2008-03-09 19:00:47 UTC (rev 7473)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst/Utils.pm 2008-03-10 20:26:05 UTC (rev 7474)
@@ -264,7 +264,9 @@
my $error;
{
local $@;
- eval "require $class;";
+ my $file = $class . '.pm';
+ $file =~ s{::}{/}g;
+ eval { CORE::require($file) };
$error = $@;
}
Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm 2008-03-09 19:00:47 UTC (rev 7473)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm 2008-03-10 20:26:05 UTC (rev 7474)
@@ -920,6 +920,9 @@
contain GET parameter key/value pairs, which will be appended to the URI
in standard fashion.
+Note that uri_for is destructive to the passed hashref. Subsequent calls
+with the same hashref may have unintended results.
+
Instead of C<$path>, you can also optionally pass a C<$action> object
which will be resolved to a path using
C<< $c->dispatcher->uri_for_action >>; if the first element of
@@ -978,7 +981,7 @@
$val = '' unless defined $val;
(map {
$_ = "$_";
- utf8::encode( $_ );
+ utf8::encode( $_ ) if utf8::is_utf8($_);
# using the URI::Escape pattern here so utf8 chars survive
s/([^A-Za-z0-9\-_.!~*'() ])/$URI::Escape::escapes{$1}/go;
s/ /+/g;
@@ -1432,6 +1435,7 @@
}
}
else {
+ # everything should be bytes at this point, but just in case
$c->response->content_length( bytes::length( $c->response->body ) );
}
}
Modified: Catalyst-Runtime/5.80/trunk/t/unit_controller_config.t
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/unit_controller_config.t 2008-03-09 19:00:47 UTC (rev 7473)
+++ Catalyst-Runtime/5.80/trunk/t/unit_controller_config.t 2008-03-10 20:26:05 UTC (rev 7474)
@@ -44,7 +44,7 @@
use base 'base_controller';
- __PACKAGE__->config( key_b => 'value_b' );
+ __PACKAGE__->config->{key_b} = 'value_b';
}
## Okay, we expect that the base controller has a config with one key
Added: Catalyst-Runtime/5.80/trunk/t/unit_core_uri_for_multibytechar.t
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/unit_core_uri_for_multibytechar.t (rev 0)
+++ Catalyst-Runtime/5.80/trunk/t/unit_core_uri_for_multibytechar.t 2008-03-10 20:26:05 UTC (rev 7474)
@@ -0,0 +1,36 @@
+use strict;
+use warnings;
+
+use FindBin;
+use File::Spec;
+use lib File::Spec->catfile($FindBin::Bin, 'lib');
+
+use Test::More tests => 5;
+
+use_ok('TestApp');
+
+my $base = 'http://127.0.0.1';
+
+my $request = Catalyst::Request->new({
+ base => URI->new($base),
+ uri => URI->new("$base/"),
+});
+
+my $context = TestApp->new({
+ request => $request,
+});
+
+
+my $uri_with_multibyte = URI->new($base);
+$uri_with_multibyte->path('/');
+$uri_with_multibyte->query_form(
+ name => '村瀬大輔',
+);
+
+# multibyte with utf8 bytes
+is($context->uri_for('/', { name => '村瀬大輔' }), $uri_with_multibyte, 'uri_for with utf8 bytes query');
+is($context->req->uri_with({ name => '村瀬大輔' }), $uri_with_multibyte, 'uri_with with utf8 bytes query');
+
+# multibyte with utf8 string
+is($context->uri_for('/', { name => "\x{6751}\x{702c}\x{5927}\x{8f14}" }), $uri_with_multibyte, 'uri_for with utf8 string query');
+is($context->req->uri_with({ name => "\x{6751}\x{702c}\x{5927}\x{8f14}" }), $uri_with_multibyte, 'uri_with with utf8 string query');
Modified: Catalyst-Runtime/5.80/trunk/t/unit_utils_load_class.t
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/unit_utils_load_class.t 2008-03-09 19:00:47 UTC (rev 7473)
+++ Catalyst-Runtime/5.80/trunk/t/unit_utils_load_class.t 2008-03-10 20:26:05 UTC (rev 7474)
@@ -3,7 +3,7 @@
use strict;
use warnings;
-use Test::More tests => 14;
+use Test::More tests => 16;
use lib "t/lib";
@@ -41,6 +41,11 @@
ok( $@, "doesn't defatalize" );
like( $@, qr/There\.pm.*\@INC/, "error looks right" );
+undef $@;
+eval { Catalyst::Utils::ensure_class_loaded("__PACKAGE__") };
+ok( $@, "doesn't defatalize" );
+like( $@, qr/__PACKAGE__\.pm.*\@INC/, "errors sanely on __PACKAGE__.pm" );
+
$@ = "foo";
Catalyst::Utils::ensure_class_loaded("TestApp::View::Dump::Response");
is( $@, "foo", '$@ is untouched' );
More information about the Catalyst-commits
mailing list