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

Jason Gottshall jgottshall at capitoladvantage.com
Tue Jun 10 20:40:37 BST 2008


Ash Berlin wrote:
> On 9 Jun 2008, at 20:06, Jason Gottshall wrote:
>> On Friday, June 06, 2008 5:19 PM, Ash Berlin <ash_cpan at firemirror.com>
>> wrote:
>>
>>> 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.
>>
>> You're referring to the fact that uri_for() returns undef in these
>> situations? So action_uri() should include a re-implementation of the
>> underlying logic of uri_for() rather than delegating to it. Am I
>> interpreting that correctly?
>>
>> Jason
> 
> It would be different logic anyway. It can be done without duplicating 
> code by checking the format/number of params before you hand off to the 
> dispatcher (which is what generates urls for actions)

Yes, of course, it should call $dispatcher->uri_for_action(). That does 
make sense. Now, as I look at that method, it delegates to the 
uri_for_action() method of the appropriate dispatch type, and that's 
where the logic lives for validating caps/args, failing with an undef 
rather than an exception. But I can't remedy that without breaking 
back-compat.

I guess I could factor out the caps/args validation in the dispatch 
type. That would allow $dispatch_type->uri_for_action() to continue to 
return undef on validation failure, but action_uri() could call the same 
routine and die appropriately. Unfortunately that does mean that 
successful validation will happen twice; I'm not sure how to avoid that, 
or even if it's worth worrying about.

Jason




More information about the Catalyst-dev mailing list