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

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Sun Dec 16 15:50:57 EST 2007


Author: jesse
Date: Sun Dec 16 15:50:56 2007
New Revision: 4708

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

Log:

* Revert mistaken commit. 
* Fix menus to properly weaken "parent" relationships (and normalize _parent and parent)


Modified: jifty/trunk/lib/Jifty/Web/Form/Field.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web/Form/Field.pm	(original)
+++ jifty/trunk/lib/Jifty/Web/Form/Field.pm	Sun Dec 16 15:50:56 2007
@@ -298,12 +298,15 @@
 
 sub action {
     my $self   = shift;
-    my $action = $self->_action(@_);
-
+    if (my $action = shift @_) {
     # If we're setting the action, we need to weaken
     # the reference to not get caught in a loop
-    Scalar::Util::weaken( $self->{_action} ) if @_;
-    return $action;
+        Scalar::Util::weaken($action);
+        return $self->_action($action);
+    }
+
+    return $self->_action();
+
 }
 
 =head2 current_value

Modified: jifty/trunk/lib/Jifty/Web/Menu.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web/Menu.pm	(original)
+++ jifty/trunk/lib/Jifty/Web/Menu.pm	Sun Dec 16 15:50:56 2007
@@ -2,9 +2,9 @@
 
 use base qw/Class::Accessor::Fast/;
 use URI;
-use Scalar::Util ();
+use Scalar::Util qw(weaken);
 
-__PACKAGE__->mk_accessors(qw(label parent sort_order link target escape_label class));
+__PACKAGE__->mk_accessors(qw(label _parent sort_order link target escape_label class));
 
 =head1 NAME
 
@@ -23,8 +23,15 @@
 
 sub new {
     my $package = shift;
+    my $args = ref($_[0]) eq 'HASH' ? shift @_ : {@_};
+
+    
+
+    $args->{'_parent'} ||= delete $args->{'parent'};
+    weaken $args->{'_parent'} if $args->{'_parent'};
+
     # Class::Accessor only wants a hashref;
-    $package->SUPER::new( ref($_[0]) eq 'HASH' ? @_ : {@_} );
+    $package->SUPER::new( $args);
 
 }
 
@@ -35,17 +42,26 @@
 
 =cut
 
-sub label {
-    my $self = shift;
-    $self->{label} = shift if @_;
-    return $self->{label};
-}
-
 =head2 parent [MENU]
 
 Gets or sets the parent L<Jifty::Web::Menu> of this item; this defaults
 to null.
 
+=cut
+
+
+sub parent {
+    my $self = shift;
+    my $parent;
+    if (@_) {
+        $parent = shift;
+        weaken $parent;
+    }
+
+    return $self->_parent($parent);
+}
+
+
 =head2 sort_order [NUMBER]
 
 Gets or sets the sort order of the item, as it will be displayed under


More information about the Jifty-commit mailing list