[Catalyst] Can't seem to use forward or detach. Any special requirements?

J. Shirley jshirley at gmail.com
Mon Apr 27 12:35:48 GMT 2009


On Mon, Apr 27, 2009 at 9:07 PM, <kakimoto at tpg.com.au> wrote:

> Hi, everyone,
> I know that most people here would understand redirect, forward and
> detach well.
> Unfortunately, there are people like myself who don't understand it that
> well and hence, after looking at the CPAN catalyst docs and J.Rockway's
> book, still fail to find a page that defines these methods and
> differentiates them clearly.
>
>  i hope someone can help shed some light here. Here it goes:
>
> Looking at the doc for Catalyst::Response->redirect (
>
> http://search.cpan.org/~flora/Catalyst-Runtime-5.80002/lib/Catalyst/Respo=
nse.pm#$res-%3Eredirect(_$url,_$status_)<http://search.cpan.org/%7Eflora/Ca=
talyst-Runtime-5.80002/lib/Catalyst/Response.pm#$res-%3Eredirect%28_$url,_$=
status_%29>
>  ),
>
> can anyone tell me
>
> - do the request parameters still stay when redirected?
> - how about the stash values? do they persist after the redirection? I
> do not think so but it's good to have some confirmation.
> - "This is a convenience method that sets the Location header to the
> redirect destination, and then sets the response status. You will want
> to  return;  or  $c-detach() > to interrupt the normal processing flow
> if you want the redirect to occur straight away"  - Could anyone please
> give some examples of this?
>
>  do we do something like:
>
> $c->res->redirect ($c->uri_for('subscriptions/confimation'));
> return 0;
>
> or something?
>
>
>
> thanks!
>
> k. akimoto
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>


STOP.  TOP. POSTING.

Put your reply BELOW.  Like everybody else here, and is the documented list
standard.

forward and detach have absolutely nothing in common with a redirect.

forward and detach are internal Catalyst actions.  It tells Catalyst, "Go
here".

Redirect is an HTTP *Response*.  It tells the browser, "Look over here".

A redirect is to a URI, composed of however you make it.  If you preserve
the request parameters, they will be there.  All you are doing is sending a
string to the web browser, that the web browser will then go to next.

Calling $c->res->redirect does not stop processing.  To stop processing, you
have to call $c->detach.

This code example:
$c->res->redirect('http://google.com');
$c->log->debug('Hello');

will print "Hello" to the log.  If you have something important after the
redirect call, it will be executed.  That is the point of the warning in the
documentation.

And please...

STOP.  TOP. POSTING.

Put your reply BELOW.  Like everybody else here, and is the documented list
standard.

-J
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20090427/2d7e5=
26c/attachment.htm


More information about the Catalyst mailing list