
ash_cpan at firemirror
Jun 6, 2008, 2:18 PM
Post #6 of 22
(4313 views)
Permalink
|
|
Re: Developing action_uri() for Catalyst 5.80
[In reply to]
|
|
On 6 Jun 2008, at 21:56, J. Shirley wrote: > On Fri, Jun 6, 2008 at 1:21 PM, Jason Gottshall > <jgottshall [at] capwiz> 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 _______________________________________________ Catalyst-dev mailing list Catalyst-dev [at] lists http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst-dev
|