Try this:<br><p><span style="font-size: x-small;"><span style="font-family: courier new,courier;">sub post_chain_root : Chained('/') CaptureArgs(0) {</span></span></p>
<p><span style="font-size: x-small;"><span style="font-family: courier new,courier;"> my ($self, $c) = @_;<br></span></span></p>
<p><span style="font-size: x-small;"><span style="font-family: courier new,courier;"> foreach my $action (@{$c->action->chain}) { <br> my $role = $action->attributes->{RequiresRole}[0]; <br> next unless $role; <br>
## test role here...<br> }<br></span></span></p>
<p><span style="font-family: courier new,courier; font-size: x-small;"><span style="font-size: small; font-family: arial,helvetica,sans-serif;"><span style="font-size: x-small;"><span style="font-family: courier new,courier;">}</span></span></span></span></p>
<p><br><span style="font-family: courier new,courier; font-size: x-small;"><span style="font-size: small; font-family: arial,helvetica,sans-serif;"><span style="font-size: x-small;"><span style="font-family: courier new,courier;"></span></span></span></span></p>
That's a bit of code that you can put in the root of a Chained chain and do something like <br><p><span style="font-family: courier new,courier; font-size: x-small;">sub create_new_post : RequiresRole('can_post') {</span></p>
<p><span style="font-family: courier new,courier; font-size: x-small;"># ...</span></p>
<p><span style="font-family: courier new,courier; font-size: x-small;">}</span></p>HTH.<br><br><br><div class="gmail_quote">On Mon, Jul 13, 2009 at 12:50 AM, Toby Corkindale <span dir="ltr"><<a href="mailto:toby.corkindale@strategicdata.com.au" target="_blank">toby.corkindale@strategicdata.com.au</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div>Devin Austin wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Check this out: <a href="http://search.cpan.org/%7Ehkclark/Catalyst-Manual-5.8000/lib/Catalyst/Manual/ExtendingCatalyst.pod#Attributes" target="_blank">http://search.cpan.org/~hkclark/Catalyst-Manual-5.8000/lib/Catalyst/Manual/ExtendingCatalyst.pod#Attributes</a> and <a href="http://search.cpan.org/%7Ehkclark/Catalyst-Manual-5.8000/lib/Catalyst/Manual/ExtendingCatalyst.pod#Action_classes" target="_blank">http://search.cpan.org/~hkclark/Catalyst-Manual-5.8000/lib/Catalyst/Manual/ExtendingCatalyst.pod#Action_classes</a><br>
</blockquote>
<br></div>
Thanks, although I had already read that before posting.<br>
<br>
As far as I can see, there is no way to pass parameters to the ActionClass. Have I missed something?<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div>
On Mon, Jul 13, 2009 at 12:27 AM, Toby Corkindale <<a href="mailto:toby.corkindale@strategicdata.com.au" target="_blank">toby.corkindale@strategicdata.com.au</a> <mailto:<a href="mailto:toby.corkindale@strategicdata.com.au" target="_blank">toby.corkindale@strategicdata.com.au</a>>> wrote:<br>
<br>
Toby Corkindale wrote:<br>
<br>
Hi,<br>
I wondered if anyone could point me towards a working example of<br>
creating custom action attribute handlers for Catalyst?<br>
<br>
eg. The contents of Catalyst::Controller::SecretAgent in the<br>
example below:<br>
<br>
<br>
package MyApp::Controller::M;<br>
use parent 'Catalyst::Controller::SecretAgent';<br>
# Provides Vehicle() and Gimmick() actions.<br>
<br>
sub bond : Vehicle('Aston Martin') {<br>
my ($self, $c) = @_;<br>
# ...<br>
}<br>
<br>
sub maxwell_smart : Gimmick('Shoe-phone') {<br>
My ($self, $c) = @_;<br>
#...<br>
}<br>
<br>
1;<br>
<br>
<br>
<br>
I should clarify what I'm after..<br>
I'd still like to be able to specify regular DispatchType attributes<br>
against the routines (eg. Local, Chained, etc), but I'd also like to<br>
have my own methods called against the other attributes I've specified.<br>
<br>
The first method I tried was:<br>
package Catalyst::Controller::SecretAgent;<br>
use strict / use warnings<br>
use parent 'Catalyst::Controller';<br>
use attributes __PACKAGE__ => \&set_vehicle, "Vehicle";<br>
sub set_vehicle { # do something }<br>
...<br>
<br>
but I think that messes up catalyst's own handling of attributes.<br>
<br>
<br>
_______________________________________________<br></div></div>
List: <a href="mailto:Catalyst@lists.scsys.co.uk" target="_blank">Catalyst@lists.scsys.co.uk</a> <mailto:<a href="mailto:Catalyst@lists.scsys.co.uk" target="_blank">Catalyst@lists.scsys.co.uk</a>><div>
<br>
Listinfo: <a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst" target="_blank">http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst</a><br>
Searchable archive:<br>
<a href="http://www.mail-archive.com/catalyst@lists.scsys.co.uk/" target="_blank">http://www.mail-archive.com/catalyst@lists.scsys.co.uk/</a><br>
Dev site: <a href="http://dev.catalyst.perl.org/" target="_blank">http://dev.catalyst.perl.org/</a><br>
<br>
<br>
<br>
<br>
-- <br>
Devin Austin<br>
<a href="http://www.codedright.net" target="_blank">http://www.codedright.net</a><br>
<a href="http://www.dreamhost.com/r.cgi?326568/hosting.html" target="_blank">http://www.dreamhost.com/r.cgi?326568/hosting.html</a> - Host with DreamHost!<br>
<br>
<br></div>
------------------------------------------------------------------------<div><br>
<br>
_______________________________________________<br>
List: <a href="mailto:Catalyst@lists.scsys.co.uk" target="_blank">Catalyst@lists.scsys.co.uk</a><br>
Listinfo: <a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst" target="_blank">http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst</a><br>
Searchable archive: <a href="http://www.mail-archive.com/catalyst@lists.scsys.co.uk/" target="_blank">http://www.mail-archive.com/catalyst@lists.scsys.co.uk/</a><br>
Dev site: <a href="http://dev.catalyst.perl.org/" target="_blank">http://dev.catalyst.perl.org/</a><br>
</div></blockquote><font color="#888888">
<br>
<br>
-- <br>
Strategic Data Pty Ltd<br>
Ph: 03 9340 9000</font><div><div></div><div><br>
<br>
_______________________________________________<br>
List: <a href="mailto:Catalyst@lists.scsys.co.uk" target="_blank">Catalyst@lists.scsys.co.uk</a><br>
Listinfo: <a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst" target="_blank">http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst</a><br>
Searchable archive: <a href="http://www.mail-archive.com/catalyst@lists.scsys.co.uk/" target="_blank">http://www.mail-archive.com/catalyst@lists.scsys.co.uk/</a><br>
Dev site: <a href="http://dev.catalyst.perl.org/" target="_blank">http://dev.catalyst.perl.org/</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Devin Austin<br><a href="http://www.codedright.net" target="_blank">http://www.codedright.net</a><br><a href="http://www.dreamhost.com/r.cgi?326568/hosting.html" target="_blank">http://www.dreamhost.com/r.cgi?326568/hosting.html</a> - Host with DreamHost!<br>