[Catalyst] [Beginner] Understanding actions and controllers - not!

Ekki Plicht (DF4OR) ep at plicht.de
Mon Aug 23 21:08:07 GMT 2010


Hi.
Somewhen over the weekend I had the impression that I em beginning to 
understand how actions and controllers work. I was wrong.

Starting with a bare minimum project, only using the standard root controller 
with three standard subs: index, default, end.

I created a view, then set up an 'index.tt' template, as well as a 
'error404.tt' template. index.tt contains the following line (via a wrapper):
	<link rel="stylesheet" href="static/css/main.css" type="text/css" />

In the default action sub I have
	$c->stash->{template} = 'error404.tt';

Using:
/localhost:3000/ -> renders index.tt nicely
/localhost:3000/foo -> renders error404.tt nicely
/localhost:3000/foo/bar -> renders error404.tt broken, the css file is not 
found!

The debug screen says:
[info] *** Request 12 (0.000/s) [21763] [Mon Aug 23 23:02:52 2010] ***
[debug] "GET" request for "foo/bar" from "127.0.0.1"
[debug] Path is "/"
[debug] Arguments are "foo/bar"
[debug] Rendering template "error404.tt"
[debug] Response Code: 404; Content-Type: text/html; charset=utf-8; Content-
Length: 3861
[info] Request took 0.100899s (9.911/s)
[...]

[info] *** Request 13 (0.000/s) [21763] [Mon Aug 23 23:02:52 2010] ***
[debug] "GET" request for "foo/static/css/main.css" from "127.0.0.1"
[debug] Path is "/"
[debug] Arguments are "foo/static/css/main.css"
[debug] Rendering template "error404.tt"
[debug] Response Code: 404; Content-Type: text/html; charset=utf-8; Content-
Length: 3877
[info] Request took 0.101907s (9.813/s)
[...]

The default sub is declared as:
	sub default :Path {


What am I missing here? Why is the first pathpart (1st argument) now suddenly 
prepended to my static path? All templates are in the same directory under 
root/

TIA,
Ekki



More information about the Catalyst mailing list