[Jifty-commit] jifty branch, master, updated. 3c7ce9559bd5adb2320f2fb4694fc881ea20b551
Jifty commits
jifty-commit at lists.jifty.org
Fri May 21 21:36:44 EDT 2010
The branch, master has been updated
via 3c7ce9559bd5adb2320f2fb4694fc881ea20b551 (commit)
via 1349843ccb872de3fb6843fc93c0ce3908c72b09 (commit)
via 607b3811c692a30fa3f46a19aa24fb08241bdff0 (commit)
via ee333fa0a1854d6a00bc740f662e632ebf5c6d5c (commit)
from 4678e73c3ae20cc275d5fc32ceccd02d444d8f9d (commit)
Summary of changes:
lib/Jifty/Continuation.pm | 17 ++++++++---------
lib/Jifty/Plugin/RequestInspector.pm | 6 ++----
lib/Jifty/Web.pm | 14 +++++++-------
lib/Jifty/Web/Session/ApacheSession.pm | 6 ++----
lib/Jifty/Web/Session/ClientSide.pm | 16 +++++++++++-----
lib/Jifty/Web/Session/JDBI.pm | 1 -
6 files changed, 30 insertions(+), 30 deletions(-)
- Log -----------------------------------------------------------------
commit ee333fa0a1854d6a00bc740f662e632ebf5c6d5c
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Fri May 21 17:19:22 2010 -0400
Keep the current plack env when restoring from a continuation
This avoids having to specifically swap in various psgi and plack
variables, as we were doing manually. It also means that the
request's ->referer, ->remote_host, etc are correct for the _current_
request, rather than being empty (if the request was hand-constructed)
or being from the stored request.
It is slightly overzealous in that ->parameters will disagree with
->env->{QUERY_STRING}, for instance, but ->parameters is correctly
inherited from the request in the continuation.
diff --git a/lib/Jifty/Continuation.pm b/lib/Jifty/Continuation.pm
index 25606e2..6b87bf9 100644
--- a/lib/Jifty/Continuation.pm
+++ b/lib/Jifty/Continuation.pm
@@ -135,10 +135,7 @@ sub new {
# from plack so we don't have plack-specified fields to hide here.
# Make sure we don't store any of the connection information
- local $self->request->{env}{"psgi.input"};
- local $self->request->{env}{"psgi.errors"};
- local $self->request->{env}{"psgix.io"};
- local $self->request->{env}{"plack.request.tempfh"};
+ local $self->request->{env};
local $self->request->{_body_parser}{input_handle} if defined $self->request->{_body_parser};
# Save it into the session
@@ -254,14 +251,16 @@ sub return {
$self->code->(Jifty->web->request)
if $self->code;
- # Set the current request to the one in the continuation
- my $input = Jifty->web->request->env->{"psgi.input"};
- my $errors = Jifty->web->request->env->{"psgi.errors"};
+ # We want to preserve the current actual request environment
+ # (headers, etc)
+ my $env = Jifty->web->request->env;
+ # Set the current request to the one in the continuation
Jifty->web->request($self->request->clone);
- Jifty->web->request->env->{"psgi.input"} = $input;
- Jifty->web->request->env->{"psgi.errors"} = $errors;
+ # Restore the environment we came in with
+ Jifty->web->request->{env} = $env;
+
return Jifty->web->request;
}
commit 607b3811c692a30fa3f46a19aa24fb08241bdff0
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Fri May 21 18:05:39 2010 -0400
Move from CGI::Cookie, which looks at ENV, to plack's way of cookie handling
diff --git a/lib/Jifty/Plugin/RequestInspector.pm b/lib/Jifty/Plugin/RequestInspector.pm
index 92f5f42..a18dfd1 100644
--- a/lib/Jifty/Plugin/RequestInspector.pm
+++ b/lib/Jifty/Plugin/RequestInspector.pm
@@ -132,8 +132,7 @@ sub new_request_inspection {
};
if (my $cookie_name = $self->on_cookie) {
- my %cookies = CGI::Cookie->fetch();
- $ret->{cookie} = $cookies{$cookie_name}->value;
+ $ret->{cookie} = $req->cookies->{$cookie_name};
}
return $ret;
}
@@ -195,8 +194,7 @@ sub should_handle_request {
return unless $url =~ $self->url_filter;
if (my $cookie_name = $self->on_cookie) {
- my %cookies = CGI::Cookie->fetch();
- return unless $cookies{$cookie_name};
+ return unless $req->cookies->{$cookie_name};
}
return 1;
diff --git a/lib/Jifty/Web.pm b/lib/Jifty/Web.pm
index cc9e512..e648efd 100644
--- a/lib/Jifty/Web.pm
+++ b/lib/Jifty/Web.pm
@@ -9,7 +9,6 @@ Jifty::Web - Web framework for a Jifty application
=cut
-use CGI::Cookie;
use XML::Writer;
use CSS::Squish;
use Digest::MD5 qw(md5_hex);
diff --git a/lib/Jifty/Web/Session/ApacheSession.pm b/lib/Jifty/Web/Session/ApacheSession.pm
index d397555..442542f 100644
--- a/lib/Jifty/Web/Session/ApacheSession.pm
+++ b/lib/Jifty/Web/Session/ApacheSession.pm
@@ -85,13 +85,11 @@ If both of those fail, creates a session in memory.
sub load {
my $self = shift;
my $session_id = shift;
- my %cookies = CGI::Cookie->fetch();
unless ($session_id) {
my $cookie_name = $self->cookie_name;
- $session_id = $cookies{$cookie_name}
- ? $cookies{$cookie_name}->value()
- : Jifty::Model::Session->new_session_id,
+ $session_id = Jifty->web->request->cookies->{$cookie_name}
+ || Jifty::Model::Session->new_session_id,
}
my $options = Jifty->config->framework('Web')->{'SessionOptions'};
diff --git a/lib/Jifty/Web/Session/ClientSide.pm b/lib/Jifty/Web/Session/ClientSide.pm
index ff46c0b..b2eda81 100644
--- a/lib/Jifty/Web/Session/ClientSide.pm
+++ b/lib/Jifty/Web/Session/ClientSide.pm
@@ -23,6 +23,7 @@ use Storable ();
use Compress::Zlib ();
use Crypt::CBC ();
use Crypt::Rijndael ();
+use CGI::Cookie;
use CGI::Cookie::Splitter ();
use MIME::Base64;
@@ -100,11 +101,11 @@ If both of those fail, creates a session in memory.
sub load {
my $self = shift;
my $session_id = shift;
- my %cookies = CGI::Cookie->fetch();
+ my %cookies = %{ Jifty->web->request->cookies };
unless ($session_id) {
my $cookie_name = $self->cookie_name;
- $session_id = $cookies{$cookie_name}->value() if $cookies{$cookie_name};
+ $session_id = $cookies{$cookie_name} if $cookies{$cookie_name};
$session_id ||= Jifty::Model::Session->new_session_id;
}
@@ -114,12 +115,17 @@ sub load {
{
local $@;
eval {
- ($data) = grep {
- $_->name eq "JIFTY_DAT_$session_id"
- } $splitter->join(values %cookies);
+ ($data)
+ = grep { $_->name eq "JIFTY_DAT_$session_id" }
+ $splitter->join(
+ map {
+ CGI::Cookie->new( -name => $_, -value => $cookies{$_} )
+ } keys %cookies
+ );
};
if ($@) {
+
# Reassembly of cookie failed -- start a new session
$session_id = Jifty::Model::Session->new_session_id;
warn $@;
diff --git a/lib/Jifty/Web/Session/JDBI.pm b/lib/Jifty/Web/Session/JDBI.pm
index 3c3b374..d919ef7 100644
--- a/lib/Jifty/Web/Session/JDBI.pm
+++ b/lib/Jifty/Web/Session/JDBI.pm
@@ -3,7 +3,6 @@ use strict;
package Jifty::Web::Session::JDBI;
use base qw/Jifty::Web::Session/;
-use CGI::Cookie ();
use DateTime ();
use Storable ();
$Storable::Deparse = 1;
commit 1349843ccb872de3fb6843fc93c0ce3908c72b09
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Fri May 21 21:34:41 2010 -0400
Minor whitespace fixups
diff --git a/lib/Jifty/Web.pm b/lib/Jifty/Web.pm
index e648efd..cfcd356 100644
--- a/lib/Jifty/Web.pm
+++ b/lib/Jifty/Web.pm
@@ -222,17 +222,16 @@ sub current_user {
}
my $object;
-
if ( defined $self->temporary_current_user ) {
return $self->temporary_current_user;
} elsif ( defined $self->{current_user} ) {
return $self->{current_user};
} elsif ( my $id = $self->session->get('user_id') ) {
- $object = Jifty->app_class({require => 0}, "CurrentUser")->new( id => $id );
+ $object = Jifty->app_class({require => 0}, "CurrentUser")->new( id => $id );
} elsif ( Jifty->admin_mode ) {
- $object = Jifty->app_class({require => 0}, "CurrentUser")->superuser;
+ $object = Jifty->app_class({require => 0}, "CurrentUser")->superuser;
} else {
- $object = Jifty->app_class({require => 0}, "CurrentUser")->new;
+ $object = Jifty->app_class({require => 0}, "CurrentUser")->new;
}
$self->{current_user} = $object;
commit 3c7ce9559bd5adb2320f2fb4694fc881ea20b551
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Fri May 21 21:34:47 2010 -0400
Only cache the current_user object if the session is loaded
This prevents negative lookups (due to the session not having been
loaded yet) from being cached indefinitely. Plugins which do things
early (in ->new_request, or the 'have_request' callback) will still
get an empty current_user, but this will no longer be incorrectly
cached for the duration of the request.
diff --git a/lib/Jifty/Web.pm b/lib/Jifty/Web.pm
index cfcd356..344ac4d 100644
--- a/lib/Jifty/Web.pm
+++ b/lib/Jifty/Web.pm
@@ -233,8 +233,10 @@ sub current_user {
} else {
$object = Jifty->app_class({require => 0}, "CurrentUser")->new;
}
-
- $self->{current_user} = $object;
+
+ # Don't cache the result unless the session had actually been
+ # loaded already.
+ $self->{current_user} = $object if $self->session->loaded;
return $object;
}
-----------------------------------------------------------------------
More information about the Jifty-commit
mailing list