[Catalyst] RFC: Reusable actions

Christopher H. Laco claco at chrislaco.com
Thu Apr 6 17:02:11 CEST 2006


Sebastian Riedel wrote:
> 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

So, how is this any better/worse than simple calling forward in all of
the specific subs toward the before/after sub?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: OpenPGP digital signature
Url : http://lists.rawmode.org/pipermail/catalyst/attachments/20060406/2baf094e/attachment.pgp 


More information about the Catalyst mailing list