Hello all,
I've been working with Chained actions, and like many others have found them to
be incredibly useful for setting up DBIC result sets before reaching an endpoint.
The one thing that has been bothering me is that to start a chain in some
controller, say MyApp::C::Admin::Services you would need to declare:
sub get_id : Chained('/') : PathPart('/admin/services') : CaptureArgs(1) {
# stash the id or do some lookup
}
It's most likely my ignorance showing, but this seems redundant and not very
DRY. That's why I'd suggest that PathPart('.') set a chained action's PathPart
to the namespace on the controller. That way you could simply do:
sub get_id : Chained('/') : PathPart('.') : CaptureArgs(1) {}
Renaming controllers or moving the action to a new controller automatically
updates the leading path to the start of the chain. I assume that this would
only make sense if the Chained attribute is '/'
I've attached a patch implementing this change, comments or criticisms much
appreciated.
Best,
Brian Kirkbride
--- /tmp/Chained.pm 2007-03-22 13:27:35.452477260 -0500
+++ /opt/catalyst/lib/Catalyst/DispatchType/Chained.pm 2007-03-22 13:41:26.697583229 -0500
@@ -228,6 +228,15 @@
);
}
+ if ($part eq '.') {
+ unless ($parent eq '/') {
+ Catalyst::Exception->throw(
+ "PathPart of '.' requires Chained('/') registering ${action}"
+ );
+ }
+ $part = $action->namespace;
+ }
+
$action->attributes->{PartPath} = [ $part ];
unshift(@{ $children->{$part} ||= [] }, $action);
_______________________________________________
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/