X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst.pm;h=8cccb9a47ec144cf82bfb1d6db41cd8b72851f68;hp=4e13edbca30d7d6cd9913476363cdb5421c6d5c6;hb=ea0e58d9d85d93bf94c3ffa6b4d7b71b200bbdf1;hpb=65d92e19962a4ac3a1c37dde7823f789946b876f diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 4e13edb..8cccb9a 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -50,9 +50,6 @@ our $DETACH = "catalyst_detach\n"; require Module::Pluggable::Fast; -# Helper script generation -our $CATALYST_SCRIPT_GEN = 27; - __PACKAGE__->mk_classdata($_) for qw/components arguments dispatcher engine log dispatcher_class engine_class context_class request_class response_class setup_finished/; @@ -779,8 +776,9 @@ sub setup { } } - $class->log->warn( - <<"EOF") if ( $ENV{CATALYST_SCRIPT_GEN} && ( $ENV{CATALYST_SCRIPT_GEN} < $Catalyst::CATALYST_SCRIPT_GEN ) ); + eval { require Catalyst::Devel; }; + if( !$@ && $ENV{CATALYST_SCRIPT_GEN} && ( $ENV{CATALYST_SCRIPT_GEN} < $Catalyst::Devel::CATALYST_SCRIPT_GEN ) ) { + $class->log->warn(<<"EOF"); You are running an old script! Please update by running (this will overwrite existing files): @@ -789,7 +787,8 @@ You are running an old script! or (this will not overwrite existing files): catalyst.pl -scripts $class EOF - + } + if ( $class->debug ) { my @plugins = (); @@ -866,6 +865,11 @@ end of the path. If the last argument to uri_for is a hash reference, it is assumed to contain GET parameter key/value pairs, which will be appended to the URI in standard fashion. +Instead of $path, you can also optionally pass a $action object which will +be resolved to a path using $c->dispatcher->uri_for_action; if the first +element of @args is an arrayref it is treated as a list of captures to be +passed to uri_for_action. + =cut sub uri_for { @@ -876,6 +880,14 @@ sub uri_for { $basepath .= '/'; my $namespace = $c->namespace || ''; + if ( Scalar::Util::blessed($path) ) { # action object + my $captures = ( scalar @args && ref $args[0] eq 'ARRAY' + ? shift(@args) + : [] ); + $path = $c->dispatcher->uri_for_action($path, $captures); + return undef unless defined($path); + } + # massage namespace, empty if absolute path $namespace =~ s/^\/// if $namespace; $namespace .= '/' if $namespace;