Skip Menu |

This queue is for tickets about the Catalyst-Plugin-Session-PSGI CPAN distribution.

Report information
The Basics
Id: 83685
Status: resolved
Worked: 15 min
Priority: 0/
Queue: Catalyst-Plugin-Session-PSGI

People
Owner: chisel [...] chizography.net
Requestors: KOKI [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.0.1
Fixed in: 0.0.2



Subject: new psgi env interface in Catalyst / Plack
Hey, Thank you for this plugin. I would like to use it, but my 'new' installation of Catalyst / Plack need a different interface to the psgi session environment. attached, the patch, thx,k
Subject: fixes_psgi_env.patch
diff --git a/lib/Catalyst/Plugin/Session/PSGI.pm b/lib/Catalyst/Plugin/Session/PSGI.pm index 1c804e3..9d188aa 100644 --- a/lib/Catalyst/Plugin/Session/PSGI.pm +++ b/lib/Catalyst/Plugin/Session/PSGI.pm @@ -2,6 +2,19 @@ package Catalyst::Plugin::Session::PSGI; use strict; use warnings; +=head2 _psgi_env + +Fetches the psgi env globally from the request env + +=cut + +sub _psgi_env { + my ( $c ) = @_; + + return $c->request->can('env') ? $c->request->env : $c->request->{_psgi_env}; +} + + =head1 EXPERIMENTAL This distribution should be considered B<experimental>. Although functional, it diff --git a/lib/Catalyst/Plugin/Session/State/PSGI.pm b/lib/Catalyst/Plugin/Session/State/PSGI.pm index adfdd03..f51443d 100644 --- a/lib/Catalyst/Plugin/Session/State/PSGI.pm +++ b/lib/Catalyst/Plugin/Session/State/PSGI.pm @@ -2,6 +2,8 @@ package Catalyst::Plugin::Session::State::PSGI; use strict; use warnings; +use Catalyst::Plugin::Session::PSGI; + =head1 EXPERIMENTAL This distribution should be considered B<experimental>. Although functional, it @@ -11,6 +13,7 @@ may break in currently undiscovered use cases. use base qw/Catalyst::Plugin::Session::State/; + =head1 SYNOPSIS use Catalyst qw/ @@ -54,7 +57,7 @@ This method retrieves the session-id from the PSGI/Plack environment information =cut sub get_session_id { my $c = shift; - my $psgi_env = $c->request->{_psgi_env}; + my $psgi_env = Catalyst::Plugin::Session::PSGI::_psgi_env($c); return unless defined $psgi_env; diff --git a/lib/Catalyst/Plugin/Session/Store/PSGI.pm b/lib/Catalyst/Plugin/Session/Store/PSGI.pm index 3955d6b..b9971a0 100644 --- a/lib/Catalyst/Plugin/Session/Store/PSGI.pm +++ b/lib/Catalyst/Plugin/Session/Store/PSGI.pm @@ -2,6 +2,8 @@ package Catalyst::Plugin::Session::Store::PSGI; use strict; use warnings; +use Catalyst::Plugin::Session::PSGI; + =head1 EXPERIMENTAL This distribution should be considered B<experimental>. Although functional, it @@ -40,7 +42,7 @@ sub get_session_data { my ($c, $id) = @_; # grab the PSGI environment - my $psgi_env = $c->request->{_psgi_env}; + my $psgi_env = Catalyst::Plugin::Session::PSGI::_psgi_env($c); return unless defined $psgi_env; @@ -63,7 +65,7 @@ sub store_session_data { my ($c, $id, $data) = @_; # grab the PSGI environment - my $psgi_env = $c->request->{_psgi_env}; + my $psgi_env = Catalyst::Plugin::Session::PSGI::_psgi_env($c); return unless defined $psgi_env;
Thanks for this patch. Looks totally sensible so I've applied it and just pushed 0.0.2 to the CPAN.
hey! thanks for so quickly applying my patch, makes my deployments much easier ;) motivated by that fact, i added a test case, just to get the basics running. https://github.com/chiselwright/catalyst-plugin-session-psgi/pull/1