From: Tomas Doran Date: Tue, 1 Sep 2009 01:11:33 +0000 (+0000) Subject: Stop calling class data methods on instances + commented out warning X-Git-Tag: 5.80012~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=df960201c8d8c22edddedced4471c14606877145 Stop calling class data methods on instances + commented out warning --- diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 17c9403..39bee16 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -646,7 +646,7 @@ If you want to search for models, pass in a regexp as the argument. sub model { my ( $c, $name, @args ) = @_; - + my $appclass = ref($c) || $c; if( $name ) { my @result = $c->_comp_search_prefixes( $name, qw/Model M/ ); return map { $c->_filter_component( $_, @args ) } @result if ref $name; @@ -659,8 +659,8 @@ sub model { return $c->model( $c->stash->{current_model} ) if $c->stash->{current_model}; } - return $c->model( $c->config->{default_model} ) - if $c->config->{default_model}; + return $c->model( $appclass->config->{default_model} ) + if $appclass->config->{default_model}; my( $comp, $rest ) = $c->_comp_search_prefixes( undef, qw/Model M/); @@ -700,6 +700,7 @@ If you want to search for views, pass in a regexp as the argument. sub view { my ( $c, $name, @args ) = @_; + my $appclass = ref($c) || $c; if( $name ) { my @result = $c->_comp_search_prefixes( $name, qw/View V/ ); return map { $c->_filter_component( $_, @args ) } @result if ref $name; @@ -712,8 +713,8 @@ sub view { return $c->view( $c->stash->{current_view} ) if $c->stash->{current_view}; } - return $c->view( $c->config->{default_view} ) - if $c->config->{default_view}; + return $c->view( $appclass->config->{default_view} ) + if $appclass->config->{default_view}; my( $comp, $rest ) = $c->_comp_search_prefixes( undef, qw/View V/); @@ -1566,9 +1567,9 @@ sub execute { sub _stats_start_execute { my ( $c, $code ) = @_; - + my $appclass = ref($c) || $c; return if ( ( $code->name =~ /^_.*/ ) - && ( !$c->config->{show_internal_actions} ) ); + && ( !$appclass->config->{show_internal_actions} ) ); my $action_name = $code->reverse(); $c->counter->{$action_name}++; @@ -1882,7 +1883,7 @@ sub prepare { $c->prepare_read; # Parse the body unless the user wants it on-demand - unless ( $c->config->{parse_on_demand} ) { + unless ( ref($c)->config->{parse_on_demand} ) { $c->prepare_body; } } @@ -2759,7 +2760,7 @@ acme: Leon Brocard Andrew Bramble -Andrew Ford +Andrew Ford EA.Ford@ford-mason.co.ukE Andrew Ruthven @@ -2775,6 +2776,14 @@ chansen: Christian Hansen chicks: Christopher Hicks +Chisel Wright C + +Danijel Milicevic C + +David Kamholz Edkamholz@cpan.orgE + +David Naughton, C + David E. Wheeler dkubb: Dan Kubb @@ -2793,6 +2802,8 @@ gabb: Danijel Milicevic Gary Ashton Jones +Gavin Henry C + Geoff Richards hobbs: Andrew Rodland @@ -2801,7 +2812,7 @@ ilmari: Dagfinn Ilmari Mannsåker jcamacho: Juan Camacho -jester: Jesse Sheidlower +jester: Jesse Sheidlower C jhannah: Jay Hannah @@ -2811,6 +2822,10 @@ Johan Lindstrom jon: Jon Schutz +Jonathan Rockway C<< >> + +Kieren Diment C + konobi: Scott McWhirter marcus: Marcus Ramberg @@ -2841,14 +2856,22 @@ rafl: Florian Ragwitz random: Roland Lammel +Robert Sedlacek C<< >> + sky: Arthur Bergman t0m: Tomas Doran Ulf Edvinsson +Viljo Marrandi C + +Will Hawes C + willert: Sebastian Willert +Yuval Kogman, C + =head1 LICENSE This library is free software. You can redistribute it and/or modify it under diff --git a/lib/Catalyst/ClassData.pm b/lib/Catalyst/ClassData.pm index f252f05..9942840 100644 --- a/lib/Catalyst/ClassData.pm +++ b/lib/Catalyst/ClassData.pm @@ -6,7 +6,7 @@ use Class::MOP; use Moose::Util (); sub mk_classdata { - my ($class, $attribute) = @_; + my ($class, $attribute, $warn_on_instance) = @_; confess("mk_classdata() is a class method, not an object method") if blessed $class; diff --git a/lib/Catalyst/Component.pm b/lib/Catalyst/Component.pm index 870418c..fe0ef6f 100644 --- a/lib/Catalyst/Component.pm +++ b/lib/Catalyst/Component.pm @@ -113,6 +113,8 @@ sub COMPONENT { sub config { my $self = shift; + # Uncomment once sane to do so + #Carp::cluck("config method called on instance") if ref $self; my $config = $self->_config || {}; if (@_) { my $newconfig = { %{@_ > 1 ? {@_} : $_[0]} }; diff --git a/lib/Catalyst/Controller.pm b/lib/Catalyst/Controller.pm index 972b6a3..b6ca882 100644 --- a/lib/Catalyst/Controller.pm +++ b/lib/Catalyst/Controller.pm @@ -137,21 +137,23 @@ 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"); } diff --git a/lib/Catalyst/Dispatcher.pm b/lib/Catalyst/Dispatcher.pm index 779c213..3d6573b 100644 --- a/lib/Catalyst/Dispatcher.pm +++ b/lib/Catalyst/Dispatcher.pm @@ -335,7 +335,7 @@ sub _invoke_as_component { reverse => "$component_class->$method", class => $component_class, namespace => Catalyst::Utils::class2prefix( - $component_class, $c->config->{case_sensitive} + $component_class, ref($c)->config->{case_sensitive} ), } ); diff --git a/lib/Catalyst/Engine.pm b/lib/Catalyst/Engine.pm index 32cac01..443975e 100644 --- a/lib/Catalyst/Engine.pm +++ b/lib/Catalyst/Engine.pm @@ -112,7 +112,7 @@ sub finalize_error { my ( $self, $c ) = @_; $c->res->content_type('text/html; charset=utf-8'); - my $name = $c->config->{name} || join(' ', split('::', ref $c)); + my $name = ref($c)->config->{name} || join(' ', split('::', ref $c)); my ( $title, $error, $infos ); if ( $c->debug ) { @@ -317,13 +317,14 @@ sets up the L object body using L sub prepare_body { my ( $self, $c ) = @_; + my $appclass = ref($c) || $c; if ( my $length = $self->read_length ) { my $request = $c->request; unless ( $request->_body ) { my $type = $request->header('Content-Type'); $request->_body(HTTP::Body->new( $type, $length )); - $request->_body->tmpdir( $c->config->{uploadtmp} ) - if exists $c->config->{uploadtmp}; + $request->_body->tmpdir( $appclass->config->{uploadtmp} ) + if exists $appclass->config->{uploadtmp}; } while ( my $buffer = $self->read($c) ) { diff --git a/lib/Catalyst/Engine/CGI.pm b/lib/Catalyst/Engine/CGI.pm index ef8aa2a..8416e09 100644 --- a/lib/Catalyst/Engine/CGI.pm +++ b/lib/Catalyst/Engine/CGI.pm @@ -57,9 +57,9 @@ sub prepare_connection { PROXY_CHECK: { - unless ( $c->config->{using_frontend_proxy} ) { + unless ( ref($c)->config->{using_frontend_proxy} ) { last PROXY_CHECK if $ENV{REMOTE_ADDR} ne '127.0.0.1'; - last PROXY_CHECK if $c->config->{ignore_frontend_proxy}; + last PROXY_CHECK if ref($c)->config->{ignore_frontend_proxy}; } last PROXY_CHECK unless $ENV{HTTP_X_FORWARDED_FOR}; @@ -126,9 +126,9 @@ sub prepare_path { # If we are running as a backend proxy, get the true hostname PROXY_CHECK: { - unless ( $c->config->{using_frontend_proxy} ) { + unless ( ref($c)->config->{using_frontend_proxy} ) { last PROXY_CHECK if $host !~ /localhost|127.0.0.1/; - last PROXY_CHECK if $c->config->{ignore_frontend_proxy}; + last PROXY_CHECK if ref($c)->config->{ignore_frontend_proxy}; } last PROXY_CHECK unless $ENV{HTTP_X_FORWARDED_HOST};