On Mon, Oct 29, 2012 at 2:07 PM, Craig Chant
<[email protected]>wrote:
> sub begin :Private {
>
>
>
> my ( $self, $c ) = @_;
>
>
>
> # Authenticate
>
> $self->AuthenticateUser();
>
*Note, you don't pass $c to AuthenticateUser here!*
> return 1;
>
>
>
> }
>
>
>
> I then have...
>
>
>
> sub AuthenticateUser {
>
>
>
> my ( $self, $c ) = @_;
>
>
>
> $c->session;
>
> if(!$c->model('Members')->LogCheck($c)){
>
> $c->uri_for_action('/login/login');
>
> }
>
>
>
> }
>
>
>
> However, $c is undefined and errors, it only works if I pass it $c from
> 'begin'..
>
>
>
> $self->AuthenticateUser($c);
>
>
>
>
>
> I was under the impression that $c was the context (Catalyst) default
> variable and was always passed to every method / subroutine.
>
>
>
> is this not the case?
>
*Right, that's not the case. It only passes to the :Chained or :Args or
:CaptureArgs methods. This leaves you free to create your own internal
methods that don't get extra $c args interfering with your logic.*
*
*
--
Will Trillich :: 812.454.6431
“Grading takes away all the fun from failing. And a huge part of education
is about failure.” -- Shimon Schocken
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/