[Jifty-commit] r2055 - jifty/trunk/lib/Jifty

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Sun Oct 22 21:05:25 EDT 2006


Author: audreyt
Date: Sun Oct 22 21:05:25 2006
New Revision: 2055

Modified:
   jifty/trunk/lib/Jifty/Action.pm
   jifty/trunk/lib/Jifty/Web.pm

Log:
* Jifty::Web / Jifty::Action: Stickiness now works on autogenerated monikers.

Modified: jifty/trunk/lib/Jifty/Action.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Action.pm	(original)
+++ jifty/trunk/lib/Jifty/Action.pm	Sun Oct 22 21:05:25 2006
@@ -104,6 +104,24 @@
 
 =cut
 
+sub generate_auto_moniker {
+    my $self = shift;
+
+    use Digest::MD5 qw(md5_hex);
+    my $frame = 1;
+    my @stack = (ref($self) || $self);
+    while (my ($pkg, $filename, $line) = caller($frame++)) {
+        push @stack, $pkg, $filename, $line;
+    }
+
+    # Increment the per-request moniker digest counter, for the case of looped action generation
+    my $digest = md5_hex("@stack");
+    my $serial = ++(Jifty->handler->stash->{monikers}{$digest});
+    my $moniker = "auto-$digest-$serial";
+    $self->log->debug("Generating moniker $moniker from stack for $self");
+    return $moniker;
+}
+
 sub new {
     my $class = shift;
     my $self = bless {}, $class;
@@ -125,19 +143,7 @@
     if ($args{'moniker'}) {
         $self->moniker($args{'moniker'});
     } else {
-        use Digest::MD5 qw(md5_hex);
-        my $frame = 1;
-        my @stack = ref($self);
-        while (my ($pkg, $filename, $line) = caller($frame++)) {
-            push @stack, $pkg, $filename, $line;
-        }
-
-        # Increment the per-request moniker digest counter, for the case of looped action generation
-        my $digest = md5_hex("@stack");
-        my $serial = ++(Jifty->handler->stash->{monikers}{$digest});
-        my $moniker = "auto-$digest-$serial";
-        $self->moniker($moniker);
-        $self->log->debug("Generating moniker $moniker from stack for $self");
+        $self->moniker($self->generate_auto_moniker);
     }
     $self->order($args{'order'});
 
@@ -399,7 +405,7 @@
 
         my $sticky = 0;
         # Check stickiness iff the values came from the request
-        if($self->values_from_request->{$field} && Jifty->web->response->result($self->moniker)) {
+        if(Jifty->web->response->result($self->moniker)) {
             $sticky = 1 if $self->sticky_on_failure and $self->result->failure;
             $sticky = 1 if $self->sticky_on_success and $self->result->success;
         }

Modified: jifty/trunk/lib/Jifty/Web.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web.pm	(original)
+++ jifty/trunk/lib/Jifty/Web.pm	Sun Oct 22 21:05:25 2006
@@ -416,17 +416,6 @@
     );
 
 
-    if ( $args{'moniker'} ) {
-        my $action_in_request = $self->request->action( $args{moniker} );
-
-    # Fields explicitly passed to new_action take precedence over those passed
-    # from the request; we read from the request to implement "sticky fields".
-    #
-        if ( $action_in_request and $action_in_request->arguments ) {
-            $args{'request_arguments'} = $action_in_request->arguments;
-        }
-    }
-
     # "Untaint" -- the implementation class is provided by the client!)
     # Allows anything that a normal package name allows
     my $class = delete $args{class};
@@ -439,6 +428,17 @@
     # Prepend the base path (probably "App::Action") unless it's there already
     $class = Jifty->api->qualify($class);
 
+    $args{moniker} ||= $class->generate_auto_moniker;
+
+    my $action_in_request = $self->request->action( $args{moniker} );
+
+    # Fields explicitly passed to new_action take precedence over those passed
+    # from the request; we read from the request to implement "sticky fields".
+    #
+    if ( $action_in_request and $action_in_request->arguments ) {
+        $args{'request_arguments'} = $action_in_request->arguments;
+    }
+
     # The implementation class is provided by the client, so this
     # isn't a "shouldn't happen"
     return unless Jifty::Util->require( $class );


More information about the Jifty-commit mailing list