[Catalyst] redirect problem
fayland
fayland at gmail.com
Mon Apr 17 07:10:19 CEST 2006
see these code:
sub test : Global {
my ( $self, $c ) = @_;
unless ($c->user_exists) {
$c->res->redirect('/login');
# return 1;
}
$c->res->body($c->user->user_id);
}
it complains like *|Can't call method "user_id" on an undefined value*,
I know I don't log in.
*But* I expect that the "redirect" should be immediately occurred. it
shouldn't meet the $c->user->user_id
Now it seems that the "redirect" runs after the whole subroutine.
Firstly make sure that the subroutine don't have any problem, then
"redirect".
but the "$c->user->user_id" is not a problem if the "user_exists".
uncomment the "return 1;" would work, but it's not such comfortable.
any thoughts?
|
--
Fayland Lam // http://www.fayland.org/
More information about the Catalyst
mailing list