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 = shift;
      my $c = $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/Controller/Form.pm

I could be horribly wrong on that. :-)

-=Chris

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/

Reply via email to