[Catalyst] Clash of the plugins: SubRequest vs Static::Simple
Matt S Trout
dbix-class at trout.me.uk
Wed Oct 5 05:02:40 CEST 2005
On Tue, Oct 04, 2005 at 10:19:36PM -0400, Andy Grundman wrote:
> >Thanks. I worked up a test that duplicates the issue which I just
> >committed. Unfortunately, it appears to be an issue with NEXT. When
> >subrequest calls $c->dispatch, NEXT has already seen the dispatch method
> >and therefore refuses to call it a second time.
> >
> >Tried this in sub_request():
> >
> >{
> > local $NEXT::SEEN = {};
> > $c->dispatch();
> >}
> >
> >but with no luck. There is probably a solution here with localizing the
> >proper NEXT data structure.
> >
> >I also changed my calls to NEXT::ACTUAL so it will die if it can't call
> >the dispatch method, rather than appearing to work and just returning
> >nothing.
>
> Aha! Thanks to mst, try this patch to SubRequest.pm and let me know if
> it works in your app.
This also appears to work -
From: "mst" at 62.69.96.251
Summary: UPDATED: NEXT.pm tweak (probably not correct with AUTOLOAD)
--- /usr/pkg/lib/perl5/site_perl/5.8.0/NEXT.pm 2003-08-13 04:55:41.000000000 +0
100
+++ lib/NEXT.pm 2005-10-05 03:44:38.000000000 +0100
@@ -40,8 +40,14 @@
croak "Can't call $wanted from $caller"
unless $caller_method eq $wanted_method;
- local ($NEXT::NEXT{$self,$wanted_method}, $NEXT::SEEN) =
- ($NEXT::NEXT{$self,$wanted_method}, $NEXT::SEEN);
+ #warn "$self $wanted_method ".join(', ',(caller(0))[0,3]);
+ my $caller_sub = $caller_class->can($caller_method);
+ local ($NEXT::NEXT{$self,$wanted_method}, $NEXT::SEEN,
+ $NEXT::LAST{$self}) =
+ ((defined $NEXT::LAST{$self} && $NEXT::LAST{$self} ne $caller_sub
+ ? (undef)
+ : $NEXT::NEXT{$self,$wanted_method}),
+ ,$NEXT::SEEN, $caller_sub);
unless ($NEXT::NEXT{$self,$wanted_method}) {
@@ -72,6 +78,7 @@
croak qq(Can't locate object method "$wanted_method" ),
qq(via package "$caller_class");
};
+ $NEXT::LAST{$self} = $call_method;
return $self->$call_method(@_[1..$#_]) if ref $call_method eq 'CODE';
no strict 'refs';
($wanted_method=${$caller_class."::AUTOLOAD"}) =~ s/.*:://
(and happily passes the NEXT tests. that does not, however, guarantee that
it's correct. could people kick it around a bit please?)
--
Matt S Trout Specialists in perl consulting, web development, and
Technical Director UNIX/Linux systems architecture and automation. Mail
Shadowcat Systems Ltd. mst (at) shadowcatsystems.co.uk for more information
+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +
More information about the Catalyst
mailing list