[Catalyst] How to call parent's process() in Catalyst::VIEW::JSON

Kroshka Yenot trashbox at cary.lv
Mon Sep 5 12:28:17 GMT 2016


Hi!

Sorry about this newbie question. I've honestly and desperatly googled a 
lot, but still have no idea how to properly call process() method from 
my view, inherited from Catalyst::View::JSON

Any advices are welcome!


I have a view in my project. It's created with a helper in a standard 
manner.

package my_app::View::JSON;

use strict;
use base 'Catalyst::View::JSON';

1;


 From my app I do following

$c->stash->{id} = 777;
$c->forward('View::JSON'); # It's not my default view


It works flawlessy, but I need to preprocess my stash to exclude or 
include some data or set additional headers.  It's a pretty standard 
logic, so I decided to create my own process method in my view, process 
my stash and then pass control to the inherited process method

# My
sub process
{
     my($self, $c) = @_;
     $self->Catalyst::View::JSON::process($self, $c);
}

is not working.

|Caught exception in my_app::View::JSON->process "Can't locate object 
method "stash" via package "my_app::View::JSON"|

I intuitively understand why (at least about $self), but don't know how 
to make magic in a propper way


Many thank in advance!




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scsys.co.uk/pipermail/catalyst/attachments/20160905/3da7eb98/attachment.htm>


More information about the Catalyst mailing list