[Catalyst] Programmatic way to determine the needed number of captures for an action?

John Napiorkowski jjn1056 at yahoo.com
Mon Nov 6 02:51:36 GMT 2006



--- Ash Berlin <ash at cpan.org> wrote:

> John Napiorkowski wrote:
> > --- Ash Berlin <ash at cpan.org> wrote:
> > 
> >> This has been discussed before, tho a fully
> >> satisfactory solution never 
> >> appeared. Something that we touched upon that
> could
> >> work was to have a 
> >> stack of actions which been used/hit in the chain
> -
> >> though this wouldn't 
> >> help when going cross controller.
> >>
> >> But yes, its something that has been niggling me
> as
> >> well.
> >>
> >> Ash
> > 
> > I came up with this hack that worked for my
> client,
> > but it's dependent on the order of the captures
> unless
> > you are using some sort of named parameter system
> for
> > them:
> > 
> > my $uri = $c->uri_for(
> > 
> >    $c->controller->action_for('list'), 
> >    $c->request->query_parameters
> > );
> > 
> > my @captures = ();
> > 	
> > foreach my $capture ( @{$c->request->captures} )
> > {
> >    last if $uri;
> > 		
> >    push @captures, $capture;	
> > 
> >    $uri = $c->uri_for(
> > 
> >       $c->controller->action_for('list'), 
> >       [@captures], 
> >       $c->request->query_parameters
> >    );
> > }
> > 
> > As you can see it far from elegant.  Basically it
> > takes advantage of the fact that $c->uri_for will
> > always return false if it can't make a uri and
> just
> > walks through your current capture list.
> > 
> > I could probably rewrite this more cleanly, but it
> was
> > the best I could come up with on a friday late
> > afternoon :)
> > 
> > --john
> 
> 
> Evil yes, but it looks like it works better than
> anything we have 
> currently ;)

It would be great if we could do something like:

$c->controller->action_for('name')->[info]

to get metadata about the action.  Although I guess
this would badly break action_for.  Not sure where to
begin with that though, any ideas? 

Another thing that I'd like to figure out is an easier
way to access methods in your custom action classes.  
Although at that point we might start to confuse the
role of the action and the controller...

--john
> 
> 
> _______________________________________________
> List: Catalyst at 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/
> 



 
__________________________________________________________________________________________
Check out the New Yahoo! Mail - Fire up a more powerful email and get things done faster. 
(http://advision.webevents.yahoo.com/mailbeta) 




More information about the Catalyst mailing list