migrate to getLineageIterator to save memory

This commit is contained in:
Doug Bell 2010-06-01 16:22:42 -05:00
parent cc87552a22
commit 2c75ab27e6
34 changed files with 794 additions and 187 deletions

View file

@ -180,9 +180,16 @@ sub getEditForm {
}
else {
my @assetsToHide = split("\n",$self->getValue("assetsToHide"));
my $children = $self->getLineage(["children"],{"returnObjects"=>1, excludeClasses=>["WebGUI::Asset::Wobject::Layout"]});
my $childIter = $self->getLineageIterator(["children"],{excludeClasses=>["WebGUI::Asset::Wobject::Layout"]});
my %childIds;
foreach my $child (@{$children}) {
while ( 1 ) {
my $child;
eval { $child = $childIter->() };
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
$session->log->error($x->full_message);
next;
}
last unless $child;
$childIds{$child->getId} = $child->getTitle;
}
$extraFields{assetsToHide} = {
@ -256,11 +263,18 @@ sub prepareView {
my %placeHolder;
my @children;
for my $child ( @{ $self->getLineage( ["children"], {
returnObjects => 1,
my $childIter = $self->getLineageIterator( ["children"], {
excludeClasses => ["WebGUI::Asset::Wobject::Layout"],
} ) } ) {
} );
while ( 1 ) {
my $child;
eval { $child = $childIter->() };
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
$session->log->error($x->full_message);
next;
}
last unless $child;
my $assetId = $child->getId;
next
if ($hidden{$assetId} || ! $child->canView);
@ -412,7 +426,15 @@ sub getContentLastModified {
# Buggo: this is a little too conservative. Children that are hidden maybe shouldn't count. Hm.
my $self = shift;
my $mtime = $self->SUPER::getContentLastModified;
foreach my $child (@{$self->getLineage(["children"],{returnObjects=>1, excludeClasses=>['WebGUI::Asset::Wobject::Layout']})}) {
my $childIter = $self->getLineageIterator(["children"],{excludeClasses=>['WebGUI::Asset::Wobject::Layout']});
while ( 1 ) {
my $child;
eval { $child = $childIter->() };
if ( my $x = WebGUI::Error->caught('WebGUI::Error::ObjectNotFound') ) {
$session->log->error($x->full_message);
next;
}
last unless $child;
my $child_mtime = $child->getContentLastModified;
$mtime = $child_mtime if ($child_mtime > $mtime);
}