[Catalyst] Catalyst action attributes
Toby Corkindale
toby.corkindale at strategicdata.com.au
Tue Jul 14 06:46:30 GMT 2009
Tomas Doran wrote:
>
> On 13 Jul 2009, at 07:50, Toby Corkindale wrote:
>
>> Devin Austin wrote:
>>> Check this out:
>>> http://search.cpan.org/~hkclark/Catalyst-Manual-5.8000/lib/Catalyst/Manual/ExtendingCatalyst.pod#Attributes
>>> and
>>> http://search.cpan.org/~hkclark/Catalyst-Manual-5.8000/lib/Catalyst/Manual/ExtendingCatalyst.pod#Action_classes
>>>
>>
>> Thanks, although I had already read that before posting.
>>
>> As far as I can see, there is no way to pass parameters to the
>> ActionClass. Have I missed something?
>
> The action class is passed the attributes when it is constructed in its
> arguments.
>
> However - before we get into this, I recommend you write an ActionRole
> (ala Catalyst::Controller::ActionRole) instead of an action class, as
> you can use multiple actionroles together (which is not the case with
> action classes).
>
> Simple example of some prior art you can steal to get you going:
>
> http://search.cpan.org/~bobtfish/Catalyst-ActionRole-FindViewByIsa-0.000002/lib/Catalyst/ActionRole/FindViewByIsa.pm
Thanks, that's great.
So to summarise, the "best practice" way of passing parameters to these
attribute-handlers is by using more attributes, that you *don't*
specifically handle, but access via $c->action->attributes->{..}
I think that's right?
Cheers,
Toby
More information about the Catalyst
mailing list