From d3478c8282de6bdf98555b3caa6ae38d6d14168c Mon Sep 17 00:00:00 2001 From: Ben Simpson Date: Mon, 19 May 2003 13:56:58 +0000 Subject: [PATCH] $class->getTree() failed to insert the dummy root into the tree for subclasses that use a dummy root. Set the name() method so that draw_ascii_tree() produces something useful --- lib/WebGUI/Persistent/Tree.pm | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/WebGUI/Persistent/Tree.pm b/lib/WebGUI/Persistent/Tree.pm index 7f48dfa57..3bfdbc011 100644 --- a/lib/WebGUI/Persistent/Tree.pm +++ b/lib/WebGUI/Persistent/Tree.pm @@ -239,7 +239,7 @@ sub getTree { unless (ref($self)) { if ($class->useDummyRoot()) { - $self = $class->dummyRoot(); + $nodes->{0} = $self = $class->dummyRoot(); } if (!defined($maxDepth)) { @@ -306,6 +306,26 @@ sub minimumFields { #------------------------------------------------------------------- +sub name { + my $self = shift; + return $self->keyColumn().':'.$self->get($self->keyColumn()); +} + +#------------------------------------------------------------------- + +# Avoid a bug in Tree::DAG_Node. +# When a new node is created and has no daughters. This sometimes causes +# problems for Tree::DAG_Node::walk_down() + +sub new { + my $class = shift; + my $self = $class->SUPER::new(@_); + $self->{daughters} ||= [] if $self; + return $self; +} + +#------------------------------------------------------------------- + =head2 motherSelfAndSisters( $keyColumnId ) Given the $keyColumnId, this method fetches the related mother and sisters.