[Catalyst] Catalyst::Controller::DBIC::Transaction Integration

Carl Franks fireartist at gmail.com
Tue Mar 24 12:19:22 GMT 2009


2009/3/16 Moritz Onken <onken at houseofdesign.de>:
>>
>>
>> If any Cat dev could point me to a Cat controller that does the action
>> registering correctly, so I can fix C-C-HTML-FormFu, I'd very much
>> appreciate it.
>
> Did you try to put this in C::C::HTML::FormFu?
>
> sub _parse_Form_attr { my ( $self ) = @_; return ( ActionClass =>
> 'HTML::FormFu::Action::Form' ); }
>
> sub form : Form { }
> would be the same as
>
> sub form : ActionClass('HTML::FormFu::Action::Form') { }
>
> and create_action() is not needed anymore.

I'm not sure how to handle it when the attribute has an argument, such as
    sub foo : Form('arg') { }

Within the _parse_Form_attr method, I can see that I get the arg as
the 4th item in @_
But I can't see any way to return it, or store it in any of the other
arguments, that would let my ActionClass' execute() method get it,
once that's called.

Only a ( $key, $value ) return value from _parse_Form_attr() is catered for.

And because _parse_Form_attr() is called before
MyApp->create_action(), I can't hide it in the action object, as I
currently do.

I see that Catalyst::Action::DBIC::Transaction uses the Controller
method-name passed to _parse_XXX_attr( $self, $c, $name, $value )
but this falls down when you have the same method name in multiple
controllers, e.g.

package MyApp::Controller::Foo;
sub edit : Local : Form('edit_foo') { }

package MyApp::Controller::Bar;
sub edit : Local : Form('edit_bar') { }

In this case, Catalyst::Action::DBIC::Transaction effectively does:
{
    edit => 'edit_foo',
    edit => 'edit_bar',
}
which breaks.

Is there a supported way of handling an attribute argument for an ActionClass?

Carl



More information about the Catalyst mailing list