[Catalyst-dev] Re: Developing action_uri() for Catalyst 5.80

Aristotle Pagaltzis pagaltzis at gmx.de
Sat Jun 7 17:09:43 BST 2008


* J. Shirley <jshirley at gmail.com> [2008-06-07 17:55]:
> On Fri, Jun 6, 2008 at 5:47 PM, Aristotle Pagaltzis <pagaltzis at gmx.de> wrote:
> > * J. Shirley <jshirley at gmail.com> [2008-06-06 23:00]:
> >> My only thought is to not use strings to denote action
> >> paths. $c->controller('MyController')->action_for('action')
> >> has served me better.
> >
> > Better how? You're still passing strings, the only difference
> > is you're passing two of them using a much more verbose
> > syntax.
> >
> > I'm not particularly wedded to the specific syntax, though,
> > as far as I care it might just as well be
> > `MyController::action` or `MyController->action` instead of
> > `/mycontroller/action`, per the recent discussion elsewhere.
> 
> I'm not sure I understand your point. If you're saying that it
> is all the same to uri_for, you are wrong.
> $c->controller('Foo')->action_for('action') isa
> Catalyst::Action object, which stringifies to $action->reverse.
> This, combined with the special handling in uri_for for
> Catalyst::Action objects make it superior.
> 
> If you are saying that $c->controller("Foo")->action_for('bar')
> is the same as '/foo/bar' then... well, I am just glad we don't
> work on the same code bases :)
> 
> But, regardless of all the above, I should correct and clarify
> my statement that I like the admittedly verbose
> $c->controller('Foo')->action_for('bar') syntax. Instead, I
> dislike passing strings. As long as the $path bit is a
> Catalyst::Action object, I think any solution is fine.

I utilize `$c->dispatcher->get_action_by_path` so I pass in a
string, and an action object comes out.

You utilize `$c->controller` and `$ctrl->action_for` so you pass
in two strings in sequence, and an action object comes out.

In what way is the latter preferrable to the former?

(There is one way: private paths use non-Perl syntax, which as I
said I’m not particularly enthused about.)

Regards,
-- 
Aristotle Pagaltzis // <http://plasmasturm.org/>



More information about the Catalyst-dev mailing list