[Catalyst] another newbie chaining question

John Napiorkowski jjn1056 at yahoo.com
Wed Sep 6 23:43:24 CEST 2006


Some debug info on this.

In my action I have:

my @actions = @{$c->action->chain};
	
my $previous = $#actions-1;
my $previous_action = $actions[$previous];
	
$c->log->dumper($previous_action);

$c->log->dumper($c->uri_for($previous_action,
$c->request->captures));

And this is what I get from the debug console:

[debug] $VAR1 = bless( {
                 'attributes' => {
                                   'CaptureArgs' => [
                                                     
0
                                                    ],
                                   'Chained' => [
                                                  '/'
                                                ],
                                   'PartPath' => [
                                                  
'templates'
                                                 ]
                                 },
                 'class' =>
'services::Controller::templates',
                 'code' => sub { "DUMMY" },
                 'name' => 'templates',
                 'namespace' => 'templates',
                 'reverse' => 'templates/templates'
               }, 'Catalyst::Action' );

[debug] $VAR1 = undef;

So it appears I got the right action object but I
can't seem to get the URI for it.  Does this have
something to do with that fact it may not have fully
dispatched yet?

--john

--- John Napiorkowski <jjn1056 at yahoo.com> wrote:

> After a little more digging I discovered that
> $c->action when inside a chained action is actually
> an
> ActionChain object.  This is like an object that
> wraps
> each action in the chain up to this point.  It has a
> method called ->chain which returns an array ref. 
> So
> I though I could get the previous action thusly:
> 
> my @actions = @{$c->action->chain};
> 
> my $previous = $#action-1;
> my $previous_action = $actions($previous);
> 
> However I find this doesn't quite work right.  Does
> anyone know if I am on the correct track?
> 
> Thanks!
> 
> John
> 
> 
> 
> --- John Napiorkowski <jjn1056 at yahoo.com> wrote:
> 
> > Hi,
> > 
> > Anyway to get the action which was previous to the
> > current one in a given chain?  I know you can get
> > the
> > previous arguments and captures but right now I'm
> > using a stash setting as a hackaround:
> > 
> > sub first :Chained CaptureArgs(1)
> > {
> >   my ($self, $c, $arg) = @_;
> >   $c->stash->{'last_action'} = $c->action;
> > }
> > 
> > sub second :Chained CaptureArgs(0)
> > {
> >   my ($self, $c, $arg) = @_;
> >  
> >   $c->log->debug("The previous action was:
> > ".$c->stash->{'last_action'});
> > }
> > 
> > I from looking at all the action code my head is
> > spinning a bit.  Anyone run into this kind of
> > problem?
> > 
> > Thanks, sorry for posting so many questions
> lately,
> > I
> > know you're all busy like me.
> > 
> > --john
> > 
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam
> > protection around 
> > http://mail.yahoo.com 
> > 
> > _______________________________________________
> > List: Catalyst at 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/
> > 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam
> protection around 
> http://mail.yahoo.com 
> 
> _______________________________________________
> List: Catalyst at 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/
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the Catalyst mailing list