[Jifty-commit] jifty branch, master, updated. 88ee57f07c54a95e3936b0a198afde0cd36eaeb9

Jifty commits jifty-commit at lists.jifty.org
Sat May 22 19:17:57 EDT 2010


The branch, master has been updated
       via  88ee57f07c54a95e3936b0a198afde0cd36eaeb9 (commit)
       via  fdaf53fd9497206935491f7d210b24b85d15ac25 (commit)
       via  66b7c06e8ad90471e03700eeed282e6ad711fe36 (commit)
       via  1532e88ee5c19e46649ae45ee4a19d5d43650f3f (commit)
       via  bae40d89fa1480cce0dbf6f66009cda6796990a4 (commit)
       via  99fb3d3e104fb8df710da78fbccb1941ad66e9ed (commit)
      from  ae21742430849de13801201fb844407fe9035b77 (commit)

Summary of changes:
 lib/Jifty/Continuation.pm    |   18 +++++++++++-------
 lib/Jifty/Request.pm         |   28 ++++++++++++++++++++--------
 t/TestApp/t/20-error-pages.t |    2 --
 3 files changed, 31 insertions(+), 17 deletions(-)

- Log -----------------------------------------------------------------
commit 99fb3d3e104fb8df710da78fbccb1941ad66e9ed
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Sat May 22 10:55:32 2010 -0400

    Remove an extraneous "diag"

diff --git a/t/TestApp/t/20-error-pages.t b/t/TestApp/t/20-error-pages.t
index 9efd026..5efeafb 100644
--- a/t/TestApp/t/20-error-pages.t
+++ b/t/TestApp/t/20-error-pages.t
@@ -13,8 +13,6 @@ use Jifty::Test::Dist tests => 1 + 2 * 29;
 use Jifty::Test::WWW::Mechanize;
 
 my $URL = Jifty::Test->make_server->started_ok;
-#my $URL = $s->started_ok;
-diag $URL;
 my $mech = Jifty::Test::WWW::Mechanize->new;
 
 for my $path ("", "/td") {

commit bae40d89fa1480cce0dbf6f66009cda6796990a4
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Sat May 22 10:55:54 2010 -0400

    POD formatting nitpick

diff --git a/lib/Jifty/Request.pm b/lib/Jifty/Request.pm
index 0bf5929..da58ad6 100644
--- a/lib/Jifty/Request.pm
+++ b/lib/Jifty/Request.pm
@@ -114,6 +114,7 @@ method of that name is called, with the I<PARAMHASH>'s value as its
 sole argument.
 
 =cut
+
 sub BUILD {
     my $self = shift;
 

commit 1532e88ee5c19e46649ae45ee4a19d5d43650f3f
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Sat May 22 10:56:27 2010 -0400

    Factor out method to create new subrequest env from top request

diff --git a/lib/Jifty/Request.pm b/lib/Jifty/Request.pm
index da58ad6..59967d0 100644
--- a/lib/Jifty/Request.pm
+++ b/lib/Jifty/Request.pm
@@ -118,13 +118,7 @@ sole argument.
 sub BUILD {
     my $self = shift;
 
-    # Copy a bunch of information off of the top Plack request
-    if ( Jifty->web->request ) {
-        my $env = Jifty->web->request->top_request->env;
-        $self->{env}{$_} = $env->{$_} for qw/psgi.version psgi.multithread psgi.multiprocess psgi.errors/;
-        # Stub in an empty input filehandle
-        $self->{env}{"psgi.input"} = Plack::Util::inline_object( read => sub {0} );
-    }
+    $self->setup_subrequest_env if Jifty->web->request;
 
     $self->{'actions'} = {};
     $self->{'state_variables'} = {};
@@ -136,6 +130,23 @@ sub BUILD {
     $self->template_arguments({});
 }
 
+=head2 setup_subrequest_env
+
+Copies the bare minimals of the plack environment from the top
+request; this is called in L</BUILD> if the request is a subrequest.
+
+=cut
+
+sub setup_subrequest_env {
+    my $self = shift;
+    # Copy a bunch of information off of the top Plack request
+    my $env = Jifty->web->request->top_request->env;
+    $self->{env} = {};
+    $self->{env}{$_} = $env->{$_} for qw/psgi.version psgi.multithread psgi.multiprocess psgi.errors/;
+    # Stub in an empty input filehandle
+    $self->{env}{"psgi.input"} = Plack::Util::inline_object( read => sub {0} );
+}
+
 =head2 clone
 
 Return a copy of the request.

commit 66b7c06e8ad90471e03700eeed282e6ad711fe36
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Sat May 22 10:57:10 2010 -0400

    We may need to clean out both the current and top request envs

diff --git a/lib/Jifty/Continuation.pm b/lib/Jifty/Continuation.pm
index 6b87bf9..2819535 100644
--- a/lib/Jifty/Continuation.pm
+++ b/lib/Jifty/Continuation.pm
@@ -131,12 +131,14 @@ sub new {
     my $key = Jifty->web->serial . "_" . int(rand(10)) . int(rand(10)) . int(rand(10)) . int(rand(10)) . int(rand(10)) . int(rand(10));
     $self->id($key);
 
-    # XXX: Jifty::Request should really just extract useful things
-    # 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};
-    local $self->request->{_body_parser}{input_handle} if defined $self->request->{_body_parser};
+    my $req = $self->request;
+    local $req->{env};
+    local $req->{_body_parser}{input_handle} if defined $req->{_body_parser};
+    # We may also need to clean out the top request, if this is a subrequest
+    $req = $req->top_request;
+    local $req->{env};
+    local $req->{_body_parser}{input_handle} if defined $req->{_body_parser};
 
     # Save it into the session
     Jifty->web->session->set_continuation($key => $self);

commit fdaf53fd9497206935491f7d210b24b85d15ac25
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Sat May 22 10:57:48 2010 -0400

    We actually want to clone over the top request env, and re-create an empty subrequest env as necessary

diff --git a/lib/Jifty/Continuation.pm b/lib/Jifty/Continuation.pm
index 2819535..41bb436 100644
--- a/lib/Jifty/Continuation.pm
+++ b/lib/Jifty/Continuation.pm
@@ -255,13 +255,15 @@ sub return {
 
     # We want to preserve the current actual request environment
     # (headers, etc)
-    my $env = Jifty->web->request->env;
+    my $env = Jifty->web->request->top_request->env;
 
     # Set the current request to the one in the continuation
     Jifty->web->request($self->request->clone);
 
     # Restore the environment we came in with
-    Jifty->web->request->{env} = $env;
+    Jifty->web->request->top_request->{env} = $env;
+    Jifty->web->request->setup_subrequest_env
+        if Jifty->web->request->is_subrequest;
 
     return Jifty->web->request;
 }

commit 88ee57f07c54a95e3936b0a198afde0cd36eaeb9
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Sat May 22 10:58:11 2010 -0400

    Use the ->method abstraction rather than going through ->{env}

diff --git a/lib/Jifty/Request.pm b/lib/Jifty/Request.pm
index 59967d0..4095951 100644
--- a/lib/Jifty/Request.pm
+++ b/lib/Jifty/Request.pm
@@ -123,7 +123,7 @@ sub BUILD {
     $self->{'actions'} = {};
     $self->{'state_variables'} = {};
     $self->{'fragments'} = {};
-    $self->{env}{'REQUEST_METHOD'} ||= 'GET';
+    $self->method('GET') unless $self->method;
 
     $self->path("/") unless $self->path;
     $self->arguments({});

-----------------------------------------------------------------------


More information about the Jifty-commit mailing list