From trashbox at cary.lv Mon Sep 5 12:28:17 2016 From: trashbox at cary.lv (Kroshka Yenot) Date: Mon, 5 Sep 2016 15:28:17 +0300 Subject: [Catalyst] How to call parent's process() in Catalyst::VIEW::JSON Message-ID: <1d7eadc6-7bac-c77e-55fa-fee40d0ca8e6@cary.lv> 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: From jorge.gonzalez at daikon.es Mon Sep 5 13:11:12 2016 From: jorge.gonzalez at daikon.es (Jorge Gonzalez) Date: Mon, 5 Sep 2016 15:11:12 +0200 Subject: [Catalyst] How to call parent's process() in Catalyst::VIEW::JSON In-Reply-To: <1d7eadc6-7bac-c77e-55fa-fee40d0ca8e6@cary.lv> References: <1d7eadc6-7bac-c77e-55fa-fee40d0ca8e6@cary.lv> Message-ID: <793c8c63-39e3-5cf6-5d89-4d0fe41fd2e0@daikon.es> 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. From trashbox at cary.lv Mon Sep 5 13:18:58 2016 From: trashbox at cary.lv (Kroshka Yenot) Date: Mon, 5 Sep 2016 16:18:58 +0300 Subject: [Catalyst] How to call parent's process() in Catalyst::VIEW::JSON In-Reply-To: <793c8c63-39e3-5cf6-5d89-4d0fe41fd2e0@daikon.es> References: <1d7eadc6-7bac-c77e-55fa-fee40d0ca8e6@cary.lv> <793c8c63-39e3-5cf6-5d89-4d0fe41fd2e0@daikon.es> Message-ID: <23a9886b-90d0-3575-6011-4a2ef3f89230@cary.lv> 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 at lists.scsys.co.uk > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > Searchable archive: http://www.mail-archive.com/catalyst at lists.scsys.co.uk/ > Dev site: http://dev.catalyst.perl.org/