[Catalyst] RFC: Reusable actions

Bill Moseley moseley at hank.org
Thu Apr 6 17:28:08 CEST 2006

On Thu, Apr 06, 2006 at 04:58:32PM +0200, Sebastian Riedel wrote:
> 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)

Ok.  That seems like it might be something that would go in the
model, instead, but more hooks will probably find their use.

I've always thought one hole is no "auto" that runs at the end.

There's begin and end that wrap a controller in the controller's
package (or nearest if not in the controller).  There's auto that
runs for the entire path to the controller.  But there's no "autoend"
that runs after the controller action (and before or after end?) that
runs for the controller path.

I had a need for that at one point, but don't remember what the need
was now. ;)

> 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' );
>      }

So you are setting up a form there?  Still seems specific to a given
controller, but I suppose you could use that to build forms that
share common elements.

Does HTML::Widget need access to $c when not validating?  If not would
that not be better in a separate package?  Maybe I'm too used to the
Rose::HTML::Object way of doing things.

Bill Moseley
moseley at hank.org

More information about the Catalyst mailing list