[Catalyst] Chained, root action, with default sub present

fREW Schmidt frioux at gmail.com
Mon Aug 10 18:07:57 GMT 2009


On Mon, Aug 10, 2009 at 1:00 PM, Matija Grabnar <matija at serverflow.com>wrot=
e:

> J. Shirley wrote:
>
>> On Sun, Aug 9, 2009 at 7:31 AM, Matija Grabnar <matija at serverflow.com<ma=
ilto:
>> matija at serverflow.com>> wrote:
>>
>>    I think this may be either a bug or something I don't understand
>>    about specifying chained actions.
>>
>>    Suppose I have a controller which has a defined default action
>>    (such as created by catalyst.pl by default, i.e.
>>
>>
>>    sub default :Path {
>>      my ( $self, $c ) =3D @_;
>>      $c->response->body( 'Page not found' );
>>      $c->response->status(404);
>>    }
>>
>>    To that I add a root action, the start of the chain, like so:
>>
>>    sub index :Chained('/') PathPart('') :Args(0) {
>>      my ( $self, $c ) =3D @_;
>>
>>      # Hello World
>>      $c->response->body( $c->welcome_message );
>>    }
>>
>>    Now, whenever I request '/' from that script, default action
>>    triggers, and the index action doesn't.
>>    If I comment out the default action, the index DOES get called.
>>
>>    Is this a bug? If not, what do I have to change to have both index
>>    and default in my root controller?
>>
>>
>> Hi Matija,
>>
>> If you change the default attributes to "Private" it will do what you
>> expect.  I think this may be a bug, though (thought this was fixed, but I
>> may be remembering wrong).
>>
> Ah, not quite. Setting private on "default" does cause index to be called
> when fetching "/", but now
> default doesn't get called for unknown paths.
>
>>
>> The index action should match "/" (though, in this circumstance you aren=
't
>> really chaining to anything, so it would make more sense to use sub inde=
x :
>> Path, which would do what you expect)
>>
>
> To demonstrate the bug, I tried to make a minimal script that still showed
> it. The original script, the one which led me to discover this bug, was
> considerably bigger, and did indeed need / as part of the chain. But ther=
e's
> no point in posting the whole, multi-controller beast if I can demonstrate
> the bug with the most basic, two subroutine controller.


I think the problem is that you have it defined as Chained.  Is that what
you want?  I think you just want

   index : Path Args(0) { ... }

-- =

fREW Schmidt
http://blog.afoolishmanifesto.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20090810/978e8=
617/attachment.htm


More information about the Catalyst mailing list