[Catalyst] proper flow control with $c->foward, in search of greater grok

Dennis Daupert ddaupert at gmail.com
Fri Jan 8 16:49:26 GMT 2010


On Fri, Jan 8, 2010 at 9:55 AM, Tomas Doran <bobtfish at bobtfish.net> wrote:

>
>>
>> $c->response->redirect($c->uri_for("/user/$user_id/blog/$blog_id/entry/l=
ist"));
>>
>
> Eww, don't do that.
>

I know, I held my nose when doing that, but in point of fact, it does work,
so in a pinch....

>
> You want
> $c->response->redirect($c->uri_for_action('/user/blog/entry/list',
> [$user_id, $blog_id]));
>

For some unknown reason, I was never able to get the redirect formatting
worked out, so I resorted to smelly workarounds. That works nicely, thank
you.


>
>> But I can't seem to _go_ to the list (this doesn't work -- I get 'invalid
>> ID'):
>> $c->go( 'My::Controller::User::Blog::Entry', 'list', [ \@captures, \@args
>> ] );
>>
>
> Not specific enough. You get 'invalid ID' where, from what?
>

My bad, sorry, that's from a debug message *somebody* coded into my app
(sigh).

>
> Please show use the debug table from app startup and for the hit in
> question which has the issue?


> At a guess what you're doing wrong is not ->go ing to the end of the chain
> - you can _only_ go to chain endpoints (rather than individual actions) as
> go does a full redispatch.
>
> Actually, I am trying to go to the end of chain:

| /user/*/blog/*/entry/list | /user/base (0)               |
|                           | -> /user/id (1)              |
|                           | -> /user/blog/base (0)       |
|                           | -> /user/blog/id (1)         |
|                           | -> /user/blog/entry/base (0) |
|                           | =3D> /user/blog/entry/list     |


But likely I don't have the go formatting correct. He's not picking up the
user id:

.--------------------------------
| Action
+--------------------------------
| /auto
| /user/base
| /user/id
| /user/blog/base
| /user/blog/id
| /user/blog/entry/base
| /user/blog/entry/add
|  -> /user/blog/entry/save
|   /auto
|   /user/base
|   /user/id
|    -> /user/not_found
|     -> /user/list
| /end
|  -> Blog::View::TT->process

I've tried various incarnations of go, but here's one:

    my @args =3D qw( $user_id  $blog_id );
    my @captures =3D $c->req->captures;

    $c->go( 'Blog::Controller::User::Blog::Entry', 'list', [ \@captures,
\@args ] );

I also tried with my @captures =3D (), @captures =3D  qw( $user_id  $blog_i=
d );

I don't see go yet.

/dennis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20100108/5c0e3=
34d/attachment.htm


More information about the Catalyst mailing list