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

Ash Berlin ash_cpan at firemirror.com
Fri Jun 6 22:18:56 BST 2008


On 6 Jun 2008, at 21:56, J. Shirley wrote:

> On Fri, Jun 6, 2008 at 1:21 PM, Jason Gottshall  
> <jgottshall at capwiz.com> wrote:
>> I'd like to establish consensus on the calling signature (and method
>> name) for action_uri(). Based on the code I've seen from others  
>> (and my
>> own bias), here's one option:
>>
>> $c->action_uri('/private/path/to/action', \@captures_if_any,
>> \%query_params);

How (if at all) are you differentiating between captures and  
arguments. I.e. take the following

sub base : Chained('/') CaptureArgs(2) { }

sub my_action : Chained('base') Args(3) { }

Currently to get the url /base/1/43/my_action/a/b/c you'd have to do

$c->uri_for($c->action('my_action'), [1, 43], 'a', 'b', 'c');

Which is... less than ideal. I'd much rather see captures and argument  
just handled as @params. Thus:

$c->action_uri('/my_action', 1,43 'a',' 'b', 'c');

or

$c->action_uri('/my_action', 1,43 'a',' 'b', 'c', { query =>  
'param' } );


Is my vote. Oh and make sure that if you pass an invalid path, number  
of captures or args that you die with an error rather than just  
blowing up. Returning undef is more hassle than its worth IMO.

>>
>>
>> Thoughts?
>>
>> Jason
>>
>
> My only thought is to not use strings to denote action paths.
> $c->controller('MyController')->action_for('action') has served me
> better.
>
> I may be in the minority on this, but I generally dislike using
> stringified private paths.  It also seems if you pass in an $action
> object, rather than a scalar string, it can help the dispatcher.

All well and good in principle - but I think its more verbose then it  
needs to be. If you don't want to user the / seperated private path  
that is common everywhere, why not take msts suggestion (?) and make  
'MyController->action' work as a private path?

-ash



More information about the Catalyst-dev mailing list