[Catalyst] Detach won't detach?
koniczynek
koniczynek at uaznia.net
Mon Jan 26 18:56:53 GMT 2009
Hello Everyone,
I am trying to accomplish what seems to be impossible. There is a
controller, and inside this controller there are 3 methods:
- auto
- do_something
- end
In auto I am testing if user is logged in, if so I am detaching to the
do_something function, if not, I am redirecting to the / In end function
there is nothing at this point. The code looks somehow like this:
sub auto :Private {
my ( $self, $c ) = @_;
$c->log->debug('action start');
if ( ! user_logged_in) {
$c->redirect( $c->req->base );
} else {
$c->detach( $c->action->{name} );
}
$c->log->debug('action end');
}
sub do_something :Path :Local {
my ( $self, $c ) = @_;
$c->log->debug('I am doing something');
$c->response->body('doing something');
}
pretty simple I think. But calling /controller/do_something produces this
kind of debug:
[debug] action start
[debug] I am doing something
[debug] action end
[debug] I am doing something
And the action box looks like this:
/controller/auto
-> /controller/do_something
/controller/do_something
/end
And here is my question - how to code this so do_something method will be
called from sub auto depending whether user is logged in and will run only
ones? Is there a way? Am I missing something? Please help, I am pulling my
hair out on this one. Thank you.
--
Michał Droździewicz
More information about the Catalyst
mailing list