[Catalyst] file paths when using catalyst controllers.
kakimoto at tpg.com.au
kakimoto at tpg.com.au
Sun Nov 9 05:08:03 GMT 2008
hi all
I have a project that runs fine in terms of the index and static pages.
All my graphics (ie logos and stuff ) load property when I am in the
index page.
I am using Template Toolkit.
Nevertheless, when I access a method in the controller, I noticed that
the graphics do not load. I checked the path and see that the controller
name is in the path hence the images cannot load.
For example:
- accessing http://localhost:3000/ is fine as all graphics load.
- accessing http://localhost:3000/subscription/list does not load the
graphics.
What this does:
1) accessed MyApp::Controller::Subscriptions->list()
2) it is defined with the following heading:
sub list :Local {
my ($self, $c) = @_;
...
}
3) I checked the terminal where myapp_server.pl was run. The
arguments were:
$VAR1 = [
'subscription',
'images',
'default',
'bg.gif'
];
I also printed out the request path ( in
MyApp::Controller::Subscription->auto() ) and it was "subscription/list".
4) the static file accesses files in the following manner :
"images/default/logo.gif" hence the request above would result in the
request being
"subscription/images/default/logo.gif"
This is how MyApp::View::HTML looks like (in relation to the setting up
of paths for static images):
--------- File extract --------------- [Start]
package myapp::View::HTML;
use strict;
use warnings;
use base 'Catalyst::View::TT';
__PACKAGE__->config({
CATALYST_VAR => 'Catalyst',
INCLUDE_PATH => [
myapp->path_to( 'root', 'src' ),
myapp->path_to( 'root', 'lib' ),
myapp->path_to( 'root', 'static' ),
],
PRE_PROCESS => 'config/main',
WRAPPER => 'site/wrapper',
ERROR => 'error.tt2',
TIMER => 0,
TEMPLATE_EXTENSION => '.tt2',
});
--------- File extract --------------- [End]
Proposed solution:
===========
*) Add source code into Root.pm such that every request to controllers
will be received there and passed on approapriately (hence ensuring that
the path stays at the root).
Nevertheless, I see a lot of restrictions in the proposed solution
above. Any ideas??
Thanks
More information about the Catalyst
mailing list