[Catalyst-dev] Issue with calling methods on the Action object

Matt S Trout dbix-class at trout.me.uk
Mon Feb 12 09:44:02 GMT 2007


On 8 Feb 2007, at 21:36, John Napiorkowski wrote:

> Hi,
>
> I noticed there is a difference in the behavior when
> accessing methods on an action depending on if that
> action is part of a chain or not.  This is because if
> an action is part of a chain the $c->action returns an
>   ActionChain object of the Chain that Action is part
> of.
>
> For the most part the ActionChain object trys hard to
> look like the Action object for the current action.
> It uses Overload to help with this.  So you can do
> stuff like $c->action->attributes and so forth.  It
> generally will DWIM.  However if the Action has a
> custom ActionClass with it's own methods or accessors,
> then trying to use those methods will return an error.

You should really be calling $c->action->chain[-1] for this.

The ActionChain only looks like the base Action to handle things that  
rely on $c->action looking like that; if you actually know it's a  
chain you shouldn't try and use the compat stuff.

-- 
Matt S Trout, Technical Director, Shadowcat Systems Ltd.
Offering custom development, consultancy and support contracts for  
Catalyst,
DBIx::Class and BAST. Contact mst (at) shadowcatsystems.co.uk for  
details.
+ Help us build a better perl ORM: http://dbix- 
class.shadowcatsystems.co.uk/ +





More information about the Catalyst-dev mailing list