FAQ
Hi,

I just started using Catalyst::Controller::ActionRole to make
authorization within my application more consistent. However, in
controllers that use FormFu for form handling, it does not work as
expected. As I am no expert in Moose-stuff, I wanted to ask if I am
doing the right thing.

As the controller needs to inherit from ActionRole and FormFu, I wrote
the following, which is possible according to the Moose manual:

use Moose;
BEGIN { extends 'Catalyst::Controller::ActionRole',
'Catalyst::Controller::HTML::FormFu' };

The form action is declared like this:

sub settings :
Chained('base')
Args(0)

Does(ACL)
RequiresRole('some-role')
ACLDetachTo('/permission_denied')

FormConfig
{
my ($self, $c) = @_;
...
}

However, depending on the order of the arguments of 'extends' either the
forms are working or authorization, but never both.

Is there a way to get both modules work together in the same
controller/action?

Best regards,

Tobias

Search Discussions

  • Peter Shangov at May 25, 2011 at 9:17 am
    Hi Tobias,

    You cannot use Controller::FormFu together with Controller::ActionRole - both inherit from Catalyst::Controller and attempting to inherit from both of them creates a mess.

    C::FF is just sugar over ordinary HTML::FormFu syntax. The C::FF docs explain exactly what 'FormConfig' and the other attributes do, so you should use that extended syntax instead, i.e.:

    sub settings :
    ? ? ? ? Chained('base')
    ? ? ? ? Args(0)
    ? ? ? ? Does(ACL)
    ? ? ? ? RequiresRole('some-role')? ? ? ?
    ACLDetachTo('/permission_denied')
    {
    ? ? my ($self, $c) = @_;
    my $form = HTML::FormFu->new;
    ??? $form->load_config_filestem('root/forms/settings');
    ...
    }

    Ideally C::FF will be implemented as an action role in the future, but this has not been done yet.

    Cheers,

    --
    Peter

    --- On Tue, 24/5/11, Tobias Klug wrote:
    From: Tobias Klug <tklug@hartle-klug.de>
    Subject: [Catalyst] Controller::ActionRole and Controller::FormFu
    To: "The elegant MVC web framework" <catalyst@lists.scsys.co.uk>
    Date: Tuesday, 24 May, 2011, 14:07
    Hi,

    I just started using Catalyst::Controller::ActionRole to
    make
    authorization within my application more consistent.
    However, in
    controllers that use FormFu for form handling, it does not
    work as
    expected. As I am no expert in Moose-stuff, I wanted to ask
    if I am
    doing the right thing.

    As the controller needs to inherit from ActionRole and
    FormFu, I wrote
    the following, which is possible according to the Moose
    manual:

    use Moose;
    BEGIN { extends 'Catalyst::Controller::ActionRole',
    'Catalyst::Controller::HTML::FormFu' };

    The form action is declared like this:

    sub settings :
    ? ? ? ? Chained('base')
    ? ? ? ? Args(0)

    ? ? ? ? Does(ACL)
    ? ? ? ? RequiresRole('some-role')
    ? ? ? ?
    ACLDetachTo('/permission_denied')

    ? ? ? ? FormConfig
    {
    ? ? my ($self, $c) = @_;
    ???...
    }

    However, depending on the order of the arguments of
    'extends' either the
    forms are working or authorization, but never both.

    Is there a way to get both modules work together in the
    same
    controller/action?

    Best regards,

    Tobias

    _______________________________________________
    List: Catalyst@lists.scsys.co.uk
    Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
    Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
    Dev site: http://dev.catalyst.perl.org/
  • Tobias Klug at May 25, 2011 at 9:37 am
    Thanks a lot for the explanation. I will try the approach you suggested.

    Cheers,

    Tobias
    On 25.05.2011 11:17, Peter Shangov wrote:
    Hi Tobias,

    You cannot use Controller::FormFu together with Controller::ActionRole - both inherit from Catalyst::Controller and attempting to inherit from both of them creates a mess.

    C::FF is just sugar over ordinary HTML::FormFu syntax. The C::FF docs explain exactly what 'FormConfig' and the other attributes do, so you should use that extended syntax instead, i.e.:

    sub settings :
    Chained('base')
    Args(0)
    Does(ACL)
    RequiresRole('some-role')
    ACLDetachTo('/permission_denied')
    {
    my ($self, $c) = @_;
    my $form = HTML::FormFu->new;
    $form->load_config_filestem('root/forms/settings');
    ...
    }

    Ideally C::FF will be implemented as an action role in the future, but this has not been done yet.

    Cheers,

    --
    Peter

    --- On Tue, 24/5/11, Tobias Klug wrote:
    From: Tobias Klug <tklug@hartle-klug.de>
    Subject: [Catalyst] Controller::ActionRole and Controller::FormFu
    To: "The elegant MVC web framework" <catalyst@lists.scsys.co.uk>
    Date: Tuesday, 24 May, 2011, 14:07
    Hi,

    I just started using Catalyst::Controller::ActionRole to
    make
    authorization within my application more consistent.
    However, in
    controllers that use FormFu for form handling, it does not
    work as
    expected. As I am no expert in Moose-stuff, I wanted to ask
    if I am
    doing the right thing.

    As the controller needs to inherit from ActionRole and
    FormFu, I wrote
    the following, which is possible according to the Moose
    manual:

    use Moose;
    BEGIN { extends 'Catalyst::Controller::ActionRole',
    'Catalyst::Controller::HTML::FormFu' };

    The form action is declared like this:

    sub settings :
    Chained('base')
    Args(0)

    Does(ACL)
    RequiresRole('some-role')

    ACLDetachTo('/permission_denied')

    FormConfig
    {
    my ($self, $c) = @_;
    ...
    }

    However, depending on the order of the arguments of
    'extends' either the
    forms are working or authorization, but never both.

    Is there a way to get both modules work together in the
    same
    controller/action?

    Best regards,

    Tobias

    _______________________________________________
    List: Catalyst@lists.scsys.co.uk
    Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
    Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
    Dev site: http://dev.catalyst.perl.org/
    _______________________________________________
    List: Catalyst@lists.scsys.co.uk
    Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
    Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
    Dev site: http://dev.catalyst.perl.org/

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedMay 24, '11 at 11:07a
activeMay 25, '11 at 9:37a
posts3
users2
websitecatalystframework.org
irc#catalyst

2 users in discussion

Tobias Klug: 2 posts Peter Shangov: 1 post

People

Translate

site design / logo © 2022 Grokbase