[Jifty-commit] r1117 - in jifty/trunk: lib/Jifty lib/Jifty/Web/Form t

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Wed May 24 13:14:46 EDT 2006


Author: alexmv
Date: Wed May 24 13:14:44 2006
New Revision: 1117

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/lib/Jifty/Request.pm
   jifty/trunk/lib/Jifty/Web.pm
   jifty/trunk/lib/Jifty/Web/Form/Clickable.pm
   jifty/trunk/t/03-form-protocol.t

Log:
 r13289 at zoq-fot-pik:  chmrr | 2006-05-24 13:13:56 -0400
  * J:ACTIONS delimits on ! instead of ; because of a CGI.pm bug with
 multipart/form (but we need a more general escaping solution)
  * Deal with case of '=' in value of button (but, you might say that
 we need a more general escaping solution)
  * Always store actions in redirects, store has_run


Modified: jifty/trunk/lib/Jifty/Request.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Request.pm	(original)
+++ jifty/trunk/lib/Jifty/Request.pm	Wed May 24 13:14:44 2006
@@ -205,8 +205,8 @@
     for my $splittable (@splittable_names) {
         delete $args{$splittable};
         for my $newarg (split /\|/, $splittable) {
-            # If there are multiple =s, you just lose.
-            my ($k, $v) = split /=/, $newarg;
+            # If your key has a '=', you may just lose
+            my ($k, $v) = split /=/, $newarg, 2;
             $args{$k} = $v;
             # The following breaks page regions and the like, sadly:
             #$args{$k} ? (ref $args{$k} ? [@{$args{$k}},$v] : [$args{$k}, $v] ) : $v;
@@ -370,7 +370,7 @@
     my $active_actions;
     if (exists $args{'J:ACTIONS'}) {
         $active_actions = {};
-        $active_actions->{$_} = 1 for split ';', $args{'J:ACTIONS'};
+        $active_actions->{$_} = 1 for split '!', $args{'J:ACTIONS'};
     } # else $active_actions stays undef
 
     # Mapping from argument types to data structure names
@@ -578,12 +578,13 @@
         order => undef,
         active => 1,
         arguments => undef,
+        has_run => undef,
         @_
     );
 
     my $action = $self->{'actions'}->{ $args{'moniker'} } || Jifty::Request::Action->new;
 
-    for my $k (qw/moniker class order active/) {
+    for my $k (qw/moniker class order active has_run/) {
         $action->$k($args{$k}) if defined $args{$k};
     } 
     

Modified: jifty/trunk/lib/Jifty/Web.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web.pm	(original)
+++ jifty/trunk/lib/Jifty/Web.pm	Wed May 24 13:14:44 2006
@@ -216,6 +216,7 @@
     for my $request_action ( $self->request->actions ) {
         $self->log->debug("Found action ".$request_action->class . " " . $request_action->moniker);
         next unless $request_action->active;
+        next if $request_action->has_run;
         unless ( Jifty->api->is_allowed( $request_action->class ) ) {
             $self->log->warn( "Attempt to call denied action '"
                     . $request_action->class
@@ -490,12 +491,12 @@
     my $self = shift;
     my $page = shift || $self->next_page;
 
-    my @unrun = grep {not $_->has_run} Jifty->web->request->actions;
+    my @actions = Jifty->web->request->actions;
 
     if (   $self->response->results
         or $self->request->state_variables
         or $self->{'state_variables'}
-        or @unrun )
+        or @actions )
     {
         my $request = Jifty::Request->new();
         $request->path($page);
@@ -503,12 +504,13 @@
           for $self->request->state_variables;
         $request->add_state_variable( key => $_, value => $self->{'state_variables'}->{$_} )
           for keys %{ $self->{'state_variables'} };
-        for (@unrun) {
+        for (@actions) {
             $request->add_action(
                 moniker   => $_->moniker,
                 class     => $_->class,
                 order     => $_->order,
-                active    => $_->active,
+                active    => $_->active && (not $_->has_run),
+                has_run   => $_->has_run,
                 arguments => $_->arguments,
             );
         }

Modified: jifty/trunk/lib/Jifty/Web/Form/Clickable.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web/Form/Clickable.pm	(original)
+++ jifty/trunk/lib/Jifty/Web/Form/Clickable.pm	Wed May 24 13:14:44 2006
@@ -364,10 +364,10 @@
             arguments => { url => $self->url } );
         $parameters{ $redirect->register_name } = ref $redirect;
         $parameters{ $redirect->form_field_name('url') } = $self->url;
-        $parameters{"J:ACTIONS"} = join( ';', @{ $self->submit }, $redirect->moniker )
+        $parameters{"J:ACTIONS"} = join( '!', @{ $self->submit }, $redirect->moniker )
           if $self->submit;
     } else {
-        $parameters{"J:ACTIONS"} = join( ';', @{ $self->submit } )
+        $parameters{"J:ACTIONS"} = join( '!', @{ $self->submit } )
           if $self->submit;
     }
 

Modified: jifty/trunk/t/03-form-protocol.t
==============================================================================
--- jifty/trunk/t/03-form-protocol.t	(original)
+++ jifty/trunk/t/03-form-protocol.t	Wed May 24 13:14:44 2006
@@ -34,7 +34,7 @@
 J:A-second: DoSomething
 J:A:F-id-second: 42
 J:A:F-something-second: bla
-J:ACTIONS: mymoniker;second
+J:ACTIONS: mymoniker!second
 --- request
 path: ~
 state_variables: {}
@@ -60,7 +60,7 @@
   J:A-second: DoSomething
   J:A:F-id-second: 42
   J:A:F-something-second: bla
-  J:ACTIONS: mymoniker;second
+  J:ACTIONS: mymoniker!second
 fragments: {}
 === two different actions
 --- form
@@ -70,7 +70,7 @@
 J:A-second: DoThat
 J:A:F-id-second: 42
 J:A:F-something-second: bla
-J:ACTIONS: mymoniker;second
+J:ACTIONS: mymoniker!second
 --- request
 path: ~
 state_variables: {}
@@ -96,7 +96,7 @@
   J:A-second: DoThat
   J:A:F-id-second: 42
   J:A:F-something-second: bla
-  J:ACTIONS: mymoniker;second
+  J:ACTIONS: mymoniker!second
 fragments: {}
 === ignore arguments without actions
 --- form
@@ -105,7 +105,7 @@
 J:A:F-something-mymoniker: else
 J:A:F-id-second: 42
 J:A:F-something-second: bla
-J:ACTIONS: mymoniker;second
+J:ACTIONS: mymoniker!second
 --- request
 path: ~
 state_variables: {}
@@ -123,7 +123,7 @@
   J:A:F-something-mymoniker: else
   J:A:F-id-second: 42
   J:A:F-something-second: bla
-  J:ACTIONS: mymoniker;second
+  J:ACTIONS: mymoniker!second
 fragments: {}
 === one active, one inactive action
 --- form
@@ -353,7 +353,7 @@
 J:A-second: DoThat
 J:A:F-id-second: 42
 J:A:F-something-second: feepy
-J:ACTIONS: mymoniker;second
+J:ACTIONS: mymoniker!second
 --- request
 path: ~
 state_variables: {}
@@ -380,7 +380,7 @@
   J:A-second: DoThat
   J:A:F-id-second: 42
   J:A:F-something-second: feepy
-  J:ACTIONS: mymoniker;second
+  J:ACTIONS: mymoniker!second
 fragments: {}
 === double fallbacks being ignored (with single fallback)
 --- form
@@ -519,5 +519,5 @@
   J:VALIDATE: 1
   J:A:F-id-second: 42
   J:A:F-something-second: bla
-  J:ACTIONS: mymoniker;second
+  J:ACTIONS: mymoniker!second
 fragments: {}


More information about the Jifty-commit mailing list