[Catalyst] base controller
Christopher H. Laco
claco at chrislaco.com
Thu May 31 13:49:03 GMT 2007
Octavian Rasnita wrote:
> how can I access the subroutines using OOP?
> =
> I don't want to access them with
> MyApp::Controller::Base::subroutine($self, $c, ...);
You have a few options. If the method has no need for $c, just do
$self->subroutine().
If it needs access to $c, you have two options. First, forward, which
passes $c automatically:
$c->forward('subroutine');
If you want the cleanliness of the first way, but still need $c, simply
use ACCEPT_CONTEXT to store a WEAKENED reference to $c in %$self, then
get it in the method.
$self->subroutine()
sub subroutine {
my $self =3D shift;
my $c =3D $self->{'_weakened_context'};
$c->Request-param(...);
}
At least that's how I've done it:
http://svn.mangoframework.com/CPAN/Mango/trunk/lib/Mango/Catalyst/Controlle=
r/Form.pm
I could be horribly wrong on that. :-)
-=3DChris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 187 bytes
Desc: OpenPGP digital signature
Url : http://lists.scsys.co.uk/pipermail/catalyst/attachments/20070531/ad62=
89f8/signature.pgp
More information about the Catalyst
mailing list