Re: [Catalyst] RFC: Chained actions with PathPart('.')

2007-03-22 Thread Christopher H. Laco
Brian Kirkbride wrote:
 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) {}

I feel the same way really. Why make we hard code the private controller
path... when I'm in the controller already...now I have to things to
change if I change the controller name...

Then again, if I'm chaining actions across controllers, verbose is
better imho.

Then again, again...chained makes my brain melt to begin with. :-)

-=Chris



signature.asc
Description: OpenPGP digital signature
___
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/


Re: [Catalyst] RFC: Chained actions with PathPart('.')

2007-03-22 Thread Brian Cassidy

Brian Kirkbride wrote:

Hello all,

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) {}



Perhaps you're looking for PathPrefix (coming to a new Catalyst near you 
... eventually -- it's in svn now.). For now, do this:


sub _parse_PathPrefix_attr {
my ( $self, $c, $name, $value ) = @_;
return PathPart = $self-path_prefix;
}

sub get_id : Chained('/') PathPrefix CaptureArgs(1) { }

You can put the _parse_PathPrefix_attr sub in a base controller and 
all of your controllers will have access to it.


-Brian

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


Re: [Catalyst] RFC: Chained actions with PathPart('.')

2007-03-22 Thread Brian Kirkbride

Brian Cassidy wrote:
Perhaps you're looking for PathPrefix (coming to a new Catalyst near you 
... eventually -- it's in svn now.). For now, do this:


sub _parse_PathPrefix_attr {
my ( $self, $c, $name, $value ) = @_;
return PathPart = $self-path_prefix;
}

sub get_id : Chained('/') PathPrefix CaptureArgs(1) { }

You can put the _parse_PathPrefix_attr sub in a base controller and 
all of your controllers will have access to it.


-Brian



Cheers!

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