[Catalyst-dev] RFC: action_uri

John Napiorkowski jjn1056 at yahoo.com
Mon Oct 2 20:44:46 CEST 2006


--- Bogdan Lucaciu <bogdan at wiz.ro> wrote:

> Hello
> 
>
$c->uri_for($c->controller('Foo::Bar')->action_for('baz'),
> bla ) is used
> a lot, and it's the correct way of specifying an URI
> for a certain
> action.
> 
> Would this alternative syntax be acceptable:
> $c->action_uri('Foo::Bar->baz', bla); ?
> 
> 
> I also thought of: $c->uri_for([qw/Foo::Bar, baz/],
> bla);
> but action_uri seems cleaner.
> 
> Better naming suggestions are welcome :)
> I will prepare the patch according to your feedback.
> 

I'd try to make sure the default values work properly,
I do:

$c->controller->action_for('action_name') 

A lot when the current controller is the one I need
the action for.  Saves a lot of typing and I don't
think it increases imbiguity too much.  Catalyst is
reasonable consistent here $c->action defaults to the
current action as well.

So something like...

$c->action_uri;  #this actions URI
$c->action_uri->( '.'=>'action_name'); #current
controller, get the action for 'action_name'

The for completeness and to ease automation tools I'd
like:

$c->action_uri->('.'=>'.');

as meaning the same as $c->action_uri.


You'd need all the other goodies that $c->uri_for has,
such an easy way to reference capture chains and 
query parameters.  I have this kind of thing a lot:

$c->uri_for($c->controller->action_for('list'),
$c->captures->[0..1], $c->request->query_parameters);

Not sure the new syntax would save me a lot of typing,
but it might make some people who where like me and
didn't realize that Catalyst had this really cool
feature until someone on the mailing list mentioned it
specifically to me.

--john


> Thanks,
> -- 
> Bogdan Lucaciu
> 
> 
> _______________________________________________
> Catalyst-dev mailing list
> Catalyst-dev at lists.rawmode.org
>
http://lists.rawmode.org/mailman/listinfo/catalyst-dev
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the Catalyst-dev mailing list