From: André Walker Date: Sat, 6 Aug 2011 05:51:52 +0000 (-0300) Subject: Request - it's definitely not a Singleton, and it needs the context X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=da87ad6a1bb6f6608ef24ea730c99df8b6252365 Request - it's definitely not a Singleton, and it needs the context --- diff --git a/lib/Catalyst/IOC/LifeCycle/Request.pm b/lib/Catalyst/IOC/LifeCycle/Request.pm index 6a5bcad..3b277da 100644 --- a/lib/Catalyst/IOC/LifeCycle/Request.pm +++ b/lib/Catalyst/IOC/LifeCycle/Request.pm @@ -1,15 +1,28 @@ package Catalyst::IOC::LifeCycle::Request; use Moose::Role; use namespace::autoclean; -with 'Bread::Board::LifeCycle::Singleton'; +with 'Bread::Board::LifeCycle'; around get => sub { my $orig = shift; my $self = shift; - my $ctx = $self->param('ctx'); + my $instance = $self->$orig(@_); + +# FIXME - +# during setup in Catalyst.pm: +# - $class->setup_actions (line 3025) +# - $c->dispatcher->setup_actions (line 2271) +# - $c->components in Catalyst/Dispatcher.pm line 604 +# which boils down to line 616 in Catalyst/IOC/Container.pm +# resolving the component _without_ the 'context' parameter. +# Should it get the context parameter? Should all calls to a +# ConstructorInjection service pass that parameter? + my $ctx = $self->param('ctx') + or return $instance; + my $stash_key = "__Catalyst_IOC_LifeCycle_Request_" . $self->name; - return $ctx->stash->{$stash_key} ||= $self->$orig(@_); + return $ctx->stash->{$stash_key} ||= $instance; }; 1;