[Catalyst] Context Object ($c)

Amit Jha shanu_040 at yahoo.co.in
Thu Feb 18 12:54:26 GMT 2010


Hi,

I have the following 2 class structure. I am unable to access the $c in get=
_name subroutine called from subroutine site_name of=A0 Myapp::Controller::=
Sites::Configuration. Can anyone help, how can I access the $c if I am call=
 a subroutine directly not by dispatching the call

!ackage Myapp::Controller::Sites;
use Moose;
use namespace::autoclean;

BEGIN {
=A0=A0=A0 BEGIN {extends 'Catalyst::Controller'; }
}

has 'id' =3D> (
is =3D> 'rw',
isa =3D> 'Int'
);

sub get_name {
=A0my ($self, $c) =3D @_;
=A0my $rs =3D $c->model(DB::Sites)->find($self->id);
=A0return $rs->name;
}

=A0
package Myapp::Controller::Sites::Configuration;

use Moose;

use namespace::autoclean;



BEGIN {

=A0=A0=A0 extends 'GISTFIND::Controller::Site';

}



sub site_name : Local {
=A0my($self, $c) =3D @_;
=A0my $obj =3D Site->new({id =3D> 3});
=A0$name =3D $obj->get_name;
}





Genius at work=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0


      Your Mail works best with the New Yahoo Optimized IE8. Get it NOW! ht=
tp://downloads.yahoo.com/in/internetexplorer/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20100218/02138=
21e/attachment.htm


More information about the Catalyst mailing list