[Catalyst] creating action classes for chained actions, trouble with overriding ->match

John Napiorkowski jjn1056 at yahoo.com
Tue May 8 22:04:01 GMT 2007


--- Matt S Trout <dbix-class at trout.me.uk> wrote:

> On Tue, Mar 20, 2007 at 01:15:48PM -0700, John
> Napiorkowski wrote:
> > I may have answered my own question.  A peer
> pointed me to:
> > 
> >
>
http://search.cpan.org/src/MRAMBERG/Catalyst-Runtime-5.7007/lib/Catalyst/DispatchType/Chained.pm
> > 
> > and down in a method called 'recurse_match' it
> does indeed seem like match is only called against
> the endpoint in a chain.  So I guess I'd like to
> find out if anyone knows the reasoning behind this. 
> I think ideally if an action class can over ride
> match, this should be allowed for all types of
> actions.  Or I am just not smart enough to know why
> not :)
> 
> Because nobody's implemented match_captures yet
> which Chained and Regex could
> then both call. Should be pretty easy if you fancy a
> go.

Let me see if I understand what the scope of this and
the effect would be.

We'd want a new method on Catalyst::ActionChain called
match_captures which could look something like

sub match_captures
{
   my ( $self, $c, @cap_args ) = @_;
   return 1; ## or 0 to fail to match.
}

Where @cap_args would the actual capture specified via
the attribute 'CaptureArgs(x)'

We'd need to patch this into (I'm guessing) the
recurse_match method for chained dispatch type to make
sure we call this new match method.

Then if you wanted an actionclass for chained actions
that are not endpoints you'd inherit from
Catalyst::ActionChain instead of Catalyst::Action

I'm a bit confused about using this for Regex since
from the source it looks like that dispatch type is
calling the regular match.  Could you please enlighten
me as to your thinking here?

I can see this would work although I am concerned
(maybe for no good reason) that action classes with
match methods wouldn't work as expected if the action
is in the middle of a chain.  So this would reduce re
usability for those action classes.  However this may
not be a problem.  Any thoughts on that?

I have some test for the way I think I'd want this to
work floating around someplace.  I'll dig them up
since that's always a good place to start.

--John

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the Catalyst mailing list