Re: [Catalyst] Applying roles that contain actions.

2012-09-07 Thread Tomas Doran

On 5 Sep 2012, at 21:48, Bill Moseley wrote:
 
 Currently I just manually apply the role directly in the existing controller, 
 so not a huge issue, but would be handy if I could just add a role to the 
 base class and pull in all the components

What's stopping you doing this?

There is no reason you can't have actions (from a role) in a base class..

Alternatively, if you want to switch things on and off from config, look at 
CatalystX::Component::Traits.

Cheers
t0m


___
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/


Re: [Catalyst] Applying roles that contain actions.

2012-09-07 Thread Lukas Thiemeier
My Last years Advent articles might help. It is a introduction to
creating Chained Catalyst actions in Moose::Role(s):

http://www.catalystframework.org/calendar/2011/10
http://www.catalystframework.org/calendar/2011/17

cheers, lukast

On 09/05/2012 10:48 PM, Bill Moseley wrote:
 I've been injecting models into Catalyst apps (either using
 CatalystX::InjectComponent or just stuffing an instance into
 $app-components hash).
 
 I'd also like to be able to apply roles to existing controllers.   If I
 try to -apply the role it fails if
 using MooseX::MethodAttributes::Role.  Which I assume is because the
 actions would not be registered with Catalyst.
 
 Is there a way to inject actions in this way?   
 
 Currently I just manually apply the role directly in the existing
 controller, so not a huge issue, but would be handy if I could just add
 a role to the base class and pull in all the components -- or
 dynamically add the actions.
 
 
 In general, what I'm after is a way to specify with
 App::Feature::Widget; in my app base class and bring in an entire feature.
 
 I'm also looking at a gatekeeper type of feature control that Facebook
 is known for:
 
 https://www.facebook.com/video/video.php?v=10100259101684977oid=9445547199comments
 https://www.facebook.com/video/video.php?v=10100259101684977oid=9445547199comments
 
 
 -- 
 Bill Moseley
 mose...@hank.org mailto:mose...@hank.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/


___
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/


Re: [Catalyst] Applying roles that contain actions.

2012-09-07 Thread Bill Moseley
On Fri, Sep 7, 2012 at 11:50 AM, Tomas Doran bobtf...@bobtfish.net wrote:


 On 5 Sep 2012, at 21:48, Bill Moseley wrote:
 
  Currently I just manually apply the role directly in the existing
 controller, so not a huge issue, but would be handy if I could just add a
 role to the base class and pull in all the components

 What's stopping you doing this?


Sorry, I wasn't very clear in that sentence.   It's a bit more involved
than this, but I'm looking at applying a controller role (one with actions)
dynamically.   So, the code ends up something like:

package MyApp;

after setup_components = sub {

my $self = shift;
my $controller $self-controller( 'Foo' );
use My::Role::With::Actions;
My::Role::With::Actions-meta-apply( $controller );


Results in:

Composing MooseX::MethodAttributes::Role::Meta::Role::Application onto
instances is unsupported



That makes sense to me -- for one thing Catalyst would not know about the
actions in the role.


-- 
Bill Moseley
mose...@hank.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/


[Catalyst] Applying roles that contain actions.

2012-09-05 Thread Bill Moseley
I've been injecting models into Catalyst apps (either using
CatalystX::InjectComponent or just stuffing an instance into
$app-components hash).

I'd also like to be able to apply roles to existing controllers.   If I try
to -apply the role it fails if using MooseX::MethodAttributes::Role.
 Which I assume is because the actions would not be registered with
Catalyst.

Is there a way to inject actions in this way?

Currently I just manually apply the role directly in the existing
controller, so not a huge issue, but would be handy if I could just add a
role to the base class and pull in all the components -- or dynamically add
the actions.


In general, what I'm after is a way to specify with App::Feature::Widget;
in my app base class and bring in an entire feature.

I'm also looking at a gatekeeper type of feature control that Facebook is
known for:

https://www.facebook.com/video/video.php?v=10100259101684977oid=9445547199comments


-- 
Bill Moseley
mose...@hank.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/