Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Users

sub Attributes (was Re: How to do pass-through login?)

 

 

Catalyst users RSS feed   Index | Next | Previous | View Threaded


zzbbyy at gmail

Jul 12, 2009, 12:44 AM

Post #1 of 2 (410 views)
Permalink
sub Attributes (was Re: How to do pass-through login?)

On Sun, Jul 12, 2009 at 1:43 AM, Tomas Doran<bobtfish[at]bobtfish.net> wrote:
> Having spoken to the the author of the above mentioned module, I've gone
> ahead and converted it to an ActionRole:
>
> http://github.com/bobtfish/catalyst-actionrole-acl/tree/master

I just had a look there:

sub foo
:Local
:Does(ACL)
:RequiresRole(admin)
:ACLDetachTo(denied)


Nice - I hope this formatting becomes a standard. Stacking of more
and more attrs on the same line was driving me crazy - I did not know
that you can put a newline there.

By the way - theoretically all this could be equivalently coded as
something like:

package MyController;
use ....
with ACL;

sub foo : Local {
($self, $c, @args ) = @_;
$self->check_acl_role( 'admin', 'denied' );


It seems that people prefer the attributes - I guess because they are
more declarative.

--
Zbigniew Lukasiak
http://brudnopis.blogspot.com/
http://perlalchemy.blogspot.com/

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


bobtfish at bobtfish

Jul 12, 2009, 5:15 AM

Post #2 of 2 (350 views)
Permalink
Re: sub Attributes (was Re: How to do pass-through login?) [In reply to]

On 12 Jul 2009, at 08:44, Zbigniew Lukasiak wrote:
> By the way - theoretically all this could be equivalently coded as
> something like:
>
> package MyController;
> use ....
> with ACL;
>
> sub foo : Local {
> ($self, $c, @args ) = @_;
> $self->check_acl_role( 'admin', 'denied' );
>
>
> It seems that people prefer the attributes - I guess because they are
> more declarative.

Oh yes, it totally can. However, an actionrole can be applied totally
by configuration...

sub foo : Local {
# Code
}

__PACKAGE__->config( actions => { foo => { Does => 'ACL',
RequiresRole => 'admin', ACLDetachTo => 'denied' }} );

no changes to code actually required, as this can obviously come from
config.. Fairly useful as the business folks seem never to be able to
decide who can do what, so making it config makes their indecision
cheaper to support. ;)

Cheers
t0m


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

Catalyst users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.