[Catalyst-dev] Re: Quick Catalyst::Plugin::SubRequest notes

Matt S Trout dbix-class at trout.me.uk
Mon Mar 10 21:33:42 GMT 2008


On Mon, Mar 03, 2008 at 11:01:27PM +0100, Aristotle Pagaltzis wrote:
> 
> * Ash Berlin <ash_cpan at firemirror.com> [2008-03-03 12:05]:
> > On 3 Mar 2008, at 10:53, Aristotle Pagaltzis wrote:
> >> 2. An `is_subrequest` query method that, obviously enough,
> >>   returns true during a subrequest.
> >
> > Why do you need this? The whole point of subreq (as I
> > understand it) is that it looks like a normal request.
> 
> In my case, there are various authorisation checks in the code
> that is invoked via subrequest that I want to relax. Since the
> superrequest has already done its auth checks when it decides
> to make the subrequest, the subrequest comes from a trusted path.
> 
> I could do this without ::SubRequest’s aid by passing a flag via
> the passed-in stash. But then I’d want to sugarify this, so in
> the end I’d have an `is_subreq` in MyApp.pm anyway, only it would
> check a stash flag. And I’d also need need to wrap `subreq` in
> MyApp.pm to always set the stash flag on the passed-in stash.
> 
> That’s not much work, admittedly, but considering how easy it is
> to write `subreq` if you’re willing to peek under the hood, why
> bother with the extra monkey work?
> 
>     sub is_subreq {
>         my $self = shift;
>         ref $self->engine eq
>         'Catalyst::Plugin::SubRequest::Internal::FakeEngine';
>     }
> 
> But in MyApp.pm, that’s a hack. It uses knowledge of ::SubRequest
> internals that aren’t advertised.

I don't think that would be sufficient in the general case.

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director                    http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/            http://www.shadowcat.co.uk/servers/



More information about the Catalyst-dev mailing list