On Nov 17, 2007, at 6:40 AM, Matt S Trout wrote:

On Fri, Nov 16, 2007 at 01:50:03PM -0500, Jason Kohles wrote:

I keep planning to dig into the dispatcher and figure out how to
implement this (and multiple PathParts), but never enough TUITs...

I intentionally -didn't- implement this when I wrote Chained; as soon as you do that the $c->uri_for($action, ...) syntax becomes ambiguous and a
whole host of other problems crop up.

Hmm, I hadn't dug into it far enough to discover those issues, I still feel like I'm just on the edge of really understanding how the dispatcher works, but not quite there yet. :)

What I'd do instead is -

package MyApp::Controller::Foo;

use base qw(MyApp::ControllerBase::Chains);

__PACKAGE__->config(object_chains = [ qw(id name email) ]);

sub id ...
sub name ...
sub email ...

Now, when Catalyst creates the Controller::Foo instance the stuff after the component method will create Controller::Foo::Id, ::Name, ::Email - Catalyst will automatically pick this up (the same way it picks up the sub- models created by e.g. Model::DBIC::Schema) and will load the Foo/Id.pm etc. files
afterwards -if- they exist.

That way you'll get /foo/id/edit, /foo/name/edit etc. actions which can be passed happily to $c->uri_for without ambiguity, and still have minimal
repeated code.

That's pretty slick, you just saved me a whole lot of repetitive typing on my current project...

--
Jason Kohles, RHCA RHCDS RHCE
[EMAIL PROTECTED] - http://www.jasonkohles.com/
"A witty saying proves nothing."  -- Voltaire



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

Reply via email to