[Jifty-commit] r1369 - in jifty/trunk: lib/Jifty

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Mon Jun 26 18:07:51 EDT 2006


Author: alexmv
Date: Mon Jun 26 18:07:51 2006
New Revision: 1369

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/lib/Jifty/Web.pm

Log:
 r14410 at zoq-fot-pik:  chmrr | 2006-06-26 17:32:35 -0400
  * Redirects use continuations for parameters now.  This is a slightly
 backwards incompatable change in that URLs of the form /foo?bar=baz
 (with embedded GET parameters) no longer work -- but they didn't work
 before, either.


Modified: jifty/trunk/lib/Jifty/Web.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web.pm	(original)
+++ jifty/trunk/lib/Jifty/Web.pm	Mon Jun 26 18:07:51 2006
@@ -547,12 +547,18 @@
 redirects to that URL rather than B<next_page>.
 
 It creates a continuation of where you want to be, and then calls it.
+If you want to redirect to a parge with parameters, pass in a
+L<Jifty::Web::Form::Clickable> object.
 
 =cut
 
 sub redirect {
     my $self = shift;
     my $page = shift || $self->next_page;
+    $page = Jifty::Web::Form::Clickable->new( url => $page )
+      unless ref $page and $page->isa("Jifty::Web::Form::Clickable");
+    my %overrides = ( @_ );
+    $page->parameter($_ => $overrides{$_}) for keys %overrides;
 
     my @actions = Jifty->web->request->actions;
 
@@ -563,7 +569,6 @@
         or @actions )
     {
         my $request = Jifty::Request->new();
-        $request->path($page);
         $request->add_state_variable( key => $_->key, value => $_->value )
           for $self->request->state_variables;
         $request->add_state_variable( key => $_, value => $self->{'state_variables'}->{$_} )
@@ -582,18 +587,19 @@
               for grep {ref $new_action->arguments->{$_} eq "Fh"}
                 keys %{$new_action->arguments || {}};
         }
+        my %parameters = ($page->parameters);
+        $request->argument($_ => $parameters{$_}) for keys %parameters;
+        $request->path($page->url);
+
         $request->continuation($self->request->continuation);
         my $cont = Jifty::Continuation->new(
             request  => $request,
             response => $self->response,
             parent   => $self->request->continuation,
         );
-        if ($page =~ /\?/) {
-            $page .= "&";
-        } else {
-            $page .= "?";
-        }
-        $page .="J:CALL=" . $cont->id;
+        $page = $page->url."?J:CALL=" . $cont->id;
+    } else {
+        $page = $page->complete_url;
     }
     $self->_redirect($page);
 }


More information about the Jifty-commit mailing list