Mailing List Archive

How to call parent's process() in Catalyst::VIEW::JSON
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!
Re: How to call parent's process() in Catalyst::VIEW::JSON [ In reply to ]
El 05/09/16 a las 14:28, Kroshka Yenot escribió:
> (...)
> # My
>
> sub process
> {
> my($self, $c) = @_;
> $self->Catalyst::View::JSON::process($self, $c);
> }
>
> is not working.
>
Shouldn't it be like this?

$self->Catalyst::View::JSON::process($c);

I.e. the method call implicitly sends the "$self" parameter as the first
one...

Regards
J.


_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/
Re: How to call parent's process() in Catalyst::VIEW::JSON [ In reply to ]
Unbelivable huge thanks! It works!

¡muchas gracias


05.09.2016 16:11, Jorge Gonzalez пишет:
> El 05/09/16 a las 14:28, Kroshka Yenot escribió:
>> (...)
>> # My
>>
>> sub process
>> {
>> my($self, $c) = @_;
>> $self->Catalyst::View::JSON::process($self, $c);
>> }
>>
>> is not working.
>>
> Shouldn't it be like this?
>
> $self->Catalyst::View::JSON::process($c);
>
> I.e. the method call implicitly sends the "$self" parameter as the first
> one...
>
> Regards
> J.
>
>
> _______________________________________________
> List: Catalyst@lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/


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