From: Yuval Kogman Date: Wed, 10 May 2006 20:40:24 +0000 (+0000) Subject: s/snippets/captures/ X-Git-Tag: 5.7099_04~594 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=2982e768f25cf78c0cab330b2d61acd850d5e760 s/snippets/captures/ --- diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 755a9ab..247a79d 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -164,7 +164,7 @@ Catalyst - The Elegant MVC Web Application Framework sub details : Regex('^product/(\w+)/details$') { my ( $self, $c ) = @_; # extract the (\w+) from the URI - my $product = $c->req->snippets->[0]; + my $product = $c->req->captures->[0]; } See L for additional information. @@ -867,7 +867,7 @@ sub uri_for { my $basepath = $base->path; $basepath =~ s/\/$//; $basepath .= '/'; - my $namespace = $c->namespace; + my $namespace = $c->namespace || ''; # massage namespace, empty if absolute path $namespace =~ s/^\///; @@ -1495,7 +1495,7 @@ sub prepare { parameters => {}, query_parameters => {}, secure => 0, - snippets => [], + captures => [], uploads => {} } ), diff --git a/lib/Catalyst/DispatchType/Regex.pm b/lib/Catalyst/DispatchType/Regex.pm index 9470297..4a27801 100644 --- a/lib/Catalyst/DispatchType/Regex.pm +++ b/lib/Catalyst/DispatchType/Regex.pm @@ -48,11 +48,11 @@ sub match { # Check path against plain text first foreach my $compiled ( @{ $self->{compiled} || [] } ) { - if ( my @snippets = ( $path =~ $compiled->{re} ) ) { + if ( my @captures = ( $path =~ $compiled->{re} ) ) { next unless $compiled->{action}->match($c); $c->req->action( $compiled->{path} ); $c->req->match($path); - $c->req->snippets( \@snippets ); + $c->req->captures( \@captures ); $c->action( $compiled->{action} ); $c->namespace( $compiled->{action}->namespace ); return 1; diff --git a/lib/Catalyst/Manual/Intro.pod b/lib/Catalyst/Manual/Intro.pod index 26491e2..561956e 100644 --- a/lib/Catalyst/Manual/Intro.pod +++ b/lib/Catalyst/Manual/Intro.pod @@ -373,9 +373,9 @@ http://localhost:3000/catalog/foo/widget23 as well. For both LocalRegex and Regex actions, if you use capturing parentheses to extract values within the matching URL, those values are available in -the C<$c-Ereq-Esnippets> array. In the above example, "widget23" +the C<$c-Ereq-Ecaptures> array. In the above example, "widget23" would capture "23" in the above example, and -C<$c-Ereq-Esnippets-E[0]> would be "23". If you want to pass +C<$c-Ereq-Ecaptures-E[0]> would be "23". If you want to pass arguments at the end of your URL, you must use regex action keys. See L below. diff --git a/lib/Catalyst/Request.pm b/lib/Catalyst/Request.pm index d8ead36..99035b3 100644 --- a/lib/Catalyst/Request.pm +++ b/lib/Catalyst/Request.pm @@ -10,7 +10,7 @@ use URI::QueryParam; __PACKAGE__->mk_accessors( qw/action address arguments cookies headers match method - protocol query_parameters secure snippets uri user/ + protocol query_parameters secure captures uri user/ ); *args = \&arguments; @@ -19,6 +19,7 @@ __PACKAGE__->mk_accessors( *params = \¶meters; *query_params = \&query_parameters; *path_info = \&path; +*snippets = \&captures; sub content_encoding { shift->headers->content_encoding(@_) } sub content_length { shift->headers->content_length(@_) } @@ -61,7 +62,7 @@ Catalyst::Request - provides information about the current client request $req->read; $req->referer; $req->secure; - $req->snippets; + $req->captures; # previously knows as snippets $req->upload; $req->uploads; $req->uri; @@ -407,11 +408,16 @@ Shortcut for $req->headers->referer. Returns the referring page. Returns true or false, indicating whether the connection is secure (https). -=head2 $req->snippets +=head2 $req->captures + +Returns a reference to an array containing regex captures. -Returns a reference to an array containing regex snippets. + my @captures = @{ $c->request->captures }; + +=head2 $req->snippets - my @snippets = @{ $c->request->snippets }; +C used to be called snippets. This is still available for backwoards +compatibility, but is considered deprecated. =head2 $req->upload