[Catalyst] Handling a path of '/'

Justin Guenther jguenther at gmail.com
Fri Dec 2 00:04:03 CET 2005


I'm trying to set up an application on Catalyst and am having some trouble
figuring out how the action handling system works. I have a method in my
base class called `display_menu() : Path('')', which I take it would handle
the empty path (i.e. a GET of ""). This method calls $c->detach('/menu'),
which displays the menu. This way, a user can get the menu by requestiong
'/' or '/menu'. This is what shows up in the debug output:

.--------------------------------------+---------------------------------------.
| Path                                 |
Private                               |
+--------------------------------------+---------------------------------------+
| /admin                               |
/admin/display_menu                   |
| /admin/menu                          |
/admin/menu                           |
| /login                               |
/login/login                          |
| /logout                              |
/login/logout                         |
| /menu                                |
/menu                                 |
'--------------------------------------+---------------------------------------'


Which looks just fine. The problem is, when I actually request '' (or '/'
for that matter) it doesn't match the action (or doesn't call it at least)

[Thu Dec  1 16:48:59 2005] [catalyst] [debug]
**********************************
[Thu Dec  1 16:48:59 2005] [catalyst] [debug] * Request 1 (0.010/s) [12726]
[Thu Dec  1 16:48:59 2005] [catalyst] [debug]
**********************************
[Thu Dec  1 16:48:59 2005] [catalyst] [debug] "GET" request for "" from "
10.114.18.52"
[Thu Dec  1 16:48:59 2005] [catalyst] [debug] Found sessionid
"e93efd746fd8396cb82be611d9d47a76" in cookie
[Thu Dec  1 16:48:59 2005] [catalyst] [debug] Found session
"e93efd746fd8396cb82be611d9d47a76"
[Thu Dec  1 16:48:59 2005] [catalyst] [debug] >> ::begin(SaskSAGE,
SaskSAGE=HASH(0x8ecdeb8))
[Thu Dec  1 16:48:59 2005] [catalyst] [debug] >> ::auto(SaskSAGE,
SaskSAGE=HASH(0x8ecdeb8))
[Thu Dec  1 16:48:59 2005] [catalyst] [debug] >> ::end(SaskSAGE,
SaskSAGE=HASH(0x8ecdeb8))
[Thu Dec  1 16:48:59 2005] [catalyst] [debug] No Mason component specified
for rendering
[Thu Dec  1 16:48:59 2005] [catalyst] [info] Request took 0.045487s (21.984
/s)
.------------------------------------------------------------------+-----------.
| Action                                                           |
Time      |
+------------------------------------------------------------------+-----------+
| /begin                                                           |
0.000068s |
| /auto                                                            |
0.018356s |
| -> SaskSAGE::View::Mason->process                                |
0.000125s |
| /end                                                             |
0.001321s |
'------------------------------------------------------------------+-----------'

The lines starting with '>>' are just some tracing debug statements I put in
each method so I could see what was happening. As you can see,
display_menu() is never called. Yet if I comment that method out, Catalyst
calls the default() method, which gives a 404 error (as it should, as this
is how I have set up default()):

[Thu Dec  1 16:52:14 2005] [catalyst] [debug]
**********************************
[Thu Dec  1 16:52:14 2005] [catalyst] [debug] * Request 1 (0.200/s) [12730]
[Thu Dec  1 16:52:14 2005] [catalyst] [debug]
**********************************
[Thu Dec  1 16:52:14 2005] [catalyst] [debug] "GET" request for "" from "
10.114.18.52"
[Thu Dec  1 16:52:14 2005] [catalyst] [debug] Found sessionid
"e93efd746fd8396cb82be611d9d47a76" in cookie
[Thu Dec  1 16:52:14 2005] [catalyst] [debug] Found session
"e93efd746fd8396cb82be611d9d47a76"
[Thu Dec  1 16:52:14 2005] [catalyst] [debug] >> ::begin(SaskSAGE,
SaskSAGE=HASH(0x8ed1374))
[Thu Dec  1 16:52:14 2005] [catalyst] [debug] >> ::auto(SaskSAGE,
SaskSAGE=HASH(0x8ed1374))
[Thu Dec  1 16:52:14 2005] [catalyst] [debug] >> ::default(SaskSAGE,
SaskSAGE=HASH(0x8ed1374))
[Thu Dec  1 16:52:14 2005] [catalyst] [debug] >> ::end(SaskSAGE,
SaskSAGE=HASH(0x8ed1374))
[Thu Dec  1 16:52:14 2005] [catalyst] [debug] Rendering component
"/error/404.phtml"
[Thu Dec  1 16:52:14 2005] [catalyst] [info] Request took 0.034335s (29.125
/s)
.------------------------------------------------------------------+-----------.
| Action                                                           |
Time      |
+------------------------------------------------------------------+-----------+
| /begin                                                           |
0.000065s |
| /auto                                                            |
0.010908s |
| /default                                                         |
0.000096s |
| -> SaskSAGE::View::Mason->process                                |
0.002537s |
| /end                                                             |
0.003393s |
'------------------------------------------------------------------+-----------'

Why isn't display_menu() being called when it is set to handle Path('')? I
tried doing something similar in a sub-controller (Admin::display_menu :
Path('')) and it worked exactly as I expected: doing a GET on "/admin"
called Admin::display_menu(), which detached to 'menu' which displayed the
admin menu.

[Thu Dec  1 16:57:53 2005] [catalyst] [debug]
**********************************
[Thu Dec  1 16:57:53 2005] [catalyst] [debug] * Request 2 (0.006/s) [12730]
[Thu Dec  1 16:57:53 2005] [catalyst] [debug]
**********************************
[Thu Dec  1 16:57:53 2005] [catalyst] [debug] "GET" request for "admin" from
"10.114.18.52"
[Thu Dec  1 16:57:53 2005] [catalyst] [debug] Found sessionid
"e93efd746fd8396cb82be611d9d47a76" in cookie
[Thu Dec  1 16:57:53 2005] [catalyst] [debug] Path is "admin"
[Thu Dec  1 16:57:53 2005] [catalyst] [debug] Found session
"e93efd746fd8396cb82be611d9d47a76"
[Thu Dec  1 16:57:53 2005] [catalyst] [debug] >> ::begin(SaskSAGE,
SaskSAGE=HASH(0x8f48d1c))
[Thu Dec  1 16:57:53 2005] [catalyst] [debug] >> ::auto(SaskSAGE,
SaskSAGE=HASH(0x8f48d1c))
[Thu Dec  1 16:57:53 2005] [catalyst] [debug] >>
Admin::auto(SaskSAGE::Controller::Admin=HASH(0x8814bd8),
SaskSAGE=HASH(0x8f48d1c))
[Thu Dec  1 16:57:53 2005] [catalyst] [debug] >>
Admin::display_menu(SaskSAGE::Controller::Admin=HASH(0x8814bd8),
SaskSAGE=HASH(0x8f48d1c))
[Thu Dec  1 16:57:53 2005] [catalyst] [debug] >>
Admin::menu(SaskSAGE::Controller::Admin=HASH(0x8814bd8),
SaskSAGE=HASH(0x8f48d1c))
[Thu Dec  1 16:57:53 2005] [catalyst] [debug] >> ::end(SaskSAGE,
SaskSAGE=HASH(0x8f48d1c))
[Thu Dec  1 16:57:53 2005] [catalyst] [debug] Rendering component
"/admin.phtml"
[Thu Dec  1 16:57:53 2005] [catalyst] [info] Request took 0.033431s (29.912
/s)
.------------------------------------------------------------------+-----------.
| Action                                                           |
Time      |
+------------------------------------------------------------------+-----------+
| /begin                                                           |
0.000063s |
| /auto                                                            |
0.007670s |
| /admin/auto                                                      |
0.000085s |
| -> /admin/menu                                                   |
0.009026s |
| /admin/display_menu                                              |
0.009451s |
| -> SaskSAGE::View::Mason->process                                |
0.007321s |
| /end                                                             |
0.008182s |
'------------------------------------------------------------------+-----------'


Am I missing something? Any help would be appreciated.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rawmode.org/pipermail/catalyst/attachments/20051201/441ee784/attachment-0001.htm


More information about the Catalyst mailing list