[Catalyst] RFC: Reusable actions

Sebastian Riedel sri at oook.de
Thu Apr 6 16:58:32 CEST 2006


06.04.2006 15:51 Bill Moseley:

> On Thu, Apr 06, 2006 at 12:27:07PM +0200, Sebastian Riedel wrote:
>> We'll start by introducing reusable actions.
>>
>> The Action(class) attribute will attach before() and after() methods
>> to the action sub, in a very aop-ish way.
>> begin and after are just placeholders, there may be more specific
>> methods for param validation and the like.
>
> Can someone explain a bit more about what this might be used for?
> Parameter validation seems very specific to the controller -- I don't
> have the exact same form posting to to different controllers.  I must
> be missing the point.

Ok, i'll try to write a short answer.

Reusable actions doesn't mean they have to be the exact same.
You may have complicated generic actions, for example to add a
new record to a dbic model. (this can be generic, dbic class  
independent)

This generic version doesn't contain any validation.
Now you just use that reusable generic action and define a validation
profile in your current action and you are done. ;)

     sub add : Local : Action('Add') {
         my ( $self, $c ) = @_;
         $c->stash->{validate} = HTML::Widget->new;
         $c->stash->{validate}->constraint( 'ASCII', 'foo' );
     }

Hope that explains it.


--
sebastian




More information about the Catalyst mailing list