[Catalyst] Loading CRUD for all tables

Michael Reece mreece at sacbee.com
Mon Apr 11 19:56:00 CEST 2005


That is an interesting approach.  I have some questions:

Does this mean the table actions are not available on the first request,
since they won't get set up until there is a request for the default action?

I find that to run more than one Catalyst application under mod_perl, I have
to __PACKAGE__->actions( {} ); before setting up my actions, or else they
get their actions confused and things start failing.  In that scenario, if
it also requires a request for the default action to set up the other
actions, wouldn't it get into a situation where the table actions are never
available?

And, in Cat5, where the actions are subroutines instead of defined via
__PACKAGE__->action, would something like this even be possible?

And, from what I've seen (on this list) of Cat5's actions, they can't be
defined dynamically ..

On 4/11/05 6:00 AM, "Frank Wiegand" <frank.wiegand at gmail.com> wrote:

> Hi,
> 
> sometimes when developing a new app, using CatMCDBI::CRUD can be tedious.
> 
> Instead of writing
> 
>   __PACKAGE__->action(
>       $table => sub my ( $self, $c ) = @_;
>       $c->form( optional => [ $class ] );
>       $c->forward($class);
>   );
> 
> for all of my tables, I just define these actions dynamically in my
> app's '!default' action:
> 
>   __PACKAGE__->action(
>       '!default' => sub {
>           my ( $self, $c ) = @_;
>           for my $class ( $c->comp("MyApp::Model::CDBI")->loader->classes ) {
>               __PACKAGE__->action(
>                   $class->table => sub {
>                       my ( $self, $c ) = @_;
>                       $c->form( optional => [ $class ] );
>                       $c->forward($class);
>                   }
>               );
>           }
> 
>           # ... more default stuff goes here
>       }
>   };
> 
> Maybe this is helpful for somebody ...
> 
> 
> Thanks, Frank
> 
> _______________________________________________
> Catalyst mailing list
> Catalyst at lists.rawmode.org
> http://lists.rawmode.org/mailman/listinfo/catalyst
> 

-- 
michael reece :: web engineer :: mreece at sacbee.com :: (916)321-1249





More information about the Catalyst mailing list