[Jifty-commit] r871 - in jifty/trunk: lib/Jifty lib/Jifty/Test/WWW

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Wed Apr 19 01:48:11 EDT 2006


Author: alexmv
Date: Wed Apr 19 01:48:10 2006
New Revision: 871

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/lib/Jifty/Action.pm
   jifty/trunk/lib/Jifty/Test/WWW/Mechanize.pm

Log:
 r12411 at zoq-fot-pik:  chmrr | 2006-04-19 01:47:57 -0400
  * A moniker can show up in more than one form.  Try harder to find
 the right one.
  * Note that skipping undef values for canonicalization is a bit odd


Modified: jifty/trunk/lib/Jifty/Action.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Action.pm	(original)
+++ jifty/trunk/lib/Jifty/Action.pm	Wed Apr 19 01:48:10 2006
@@ -573,6 +573,7 @@
     my $value = $self->argument_value($field);
     my $default_method = 'canonicalize_' . $field;
 
+    # XXX TODO: Do we really want to skip undef values?
     return unless defined $value;
 
     if ( $field_info->{canonicalizer}

Modified: jifty/trunk/lib/Jifty/Test/WWW/Mechanize.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Test/WWW/Mechanize.pm	(original)
+++ jifty/trunk/lib/Jifty/Test/WWW/Mechanize.pm	Wed Apr 19 01:48:10 2006
@@ -74,11 +74,8 @@
     my $moniker = shift;
     my %args = @_;
 
-    my $action_form = $self->action_form($moniker);
-    
-    unless ($action_form) {
-        return;
-    } 
+    my $action_form = $self->action_form($moniker, keys %args);
+    return unless $action_form;
 
     for my $arg (keys %args) {
         my $input = $action_form->find_input("J:A:F-$arg-$moniker");
@@ -109,25 +106,29 @@
     $Test->ok($ret, "Filled in action $moniker");
 } 
 
-=head2 action_form MONIKER
+=head2 action_form MONIKER [ARGUMENTNAMES]
 
-Returns the form (as an L<HTML::Form> object) corresponding to the given moniker, and
-also selects it as the current form.  Returns undef if it can't be found.
+Returns the form (as an L<HTML::Form> object) corresponding to the
+given moniker (which also contains inputs for the given
+argumentnames), and also selects it as the current form.  Returns
+undef if it can't be found.
 
 =cut
 
 sub action_form {
     my $self = shift;
     my $moniker = shift;
+    my @fields = @_;
     Carp::confess("No moniker") unless $moniker;
 
     my $i;
     for my $form ($self->forms) {
         $i++;
-        if ($form->find_input("J:A-$moniker", "hidden")) {
-            $self->form_number($i); #select it, for $mech->submit etc
-            return $form;
-        } 
+        next unless $form->find_input("J:A-$moniker", "hidden");
+        next if grep {not $form->find_input("J:A:F-$_-$moniker")} @fields;
+
+        $self->form_number($i); #select it, for $mech->submit etc
+        return $form;
     } 
     return;
 } 
@@ -144,7 +145,7 @@
     my $moniker = shift;
     my $field = shift;
 
-    my $action_form = $self->action_form($moniker);
+    my $action_form = $self->action_form($moniker, $field);
     return unless $action_form;
     
     my $input = $action_form->find_input("J:A:F-$field-$moniker");


More information about the Jifty-commit mailing list