changeset 151:e36ffd8c29db

Fixed major bug in conversion from a POST request to the DOM document (when instanceId == 0) minor fixes
author wizard
date Fri, 20 Aug 2010 16:33:37 +0400
parents 4369d5458bb6
children 1e7f03414b65
files Lib/IMPL/DOM/Transform/PostToDOM.pm Lib/IMPL/Object/List.pm Lib/IMPL/Web/DOM/FileNode.pm
diffstat 3 files changed, 22 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/Lib/IMPL/DOM/Transform/PostToDOM.pm	Fri Aug 20 08:28:43 2010 +0400
+++ b/Lib/IMPL/DOM/Transform/PostToDOM.pm	Fri Aug 20 16:33:37 2010 +0400
@@ -51,7 +51,7 @@
     	my $value = $data->{$key->[0]};
     	my $node = $navi->NavigateCreate($key->[1]);
     	
-    	$node->nodeProperty(instanceId => $key->[2]) if $key->[2];
+    	$node->nodeProperty(instanceId => $key->[2]) if defined $key->[2];
     	
     	$this->Transform($value);
     	
--- a/Lib/IMPL/Object/List.pm	Fri Aug 20 08:28:43 2010 +0400
+++ b/Lib/IMPL/Object/List.pm	Fri Aug 20 16:33:37 2010 +0400
@@ -68,6 +68,24 @@
     return $this;
 }
 
+sub FindItem {
+	my ($this,$item) = @_;
+	
+	for (my $i = 0; $i < @$this; $i++ ) {
+		return $i if $this->[$i] == $item
+	}
+	return undef;
+}
+
+sub FindItemStr {
+	my ($this,$item) = @_;
+	
+	for (my $i = 0; $i < @$this; $i++ ) {
+		return $i if $this->[$i] eq $item
+	}
+	return undef;
+}
+
 sub save {
 	my ($this,$ctx) = @_;
 	
--- a/Lib/IMPL/Web/DOM/FileNode.pm	Fri Aug 20 08:28:43 2010 +0400
+++ b/Lib/IMPL/Web/DOM/FileNode.pm	Fri Aug 20 16:33:37 2010 +0400
@@ -13,7 +13,7 @@
 			$this->_parameterName() or
 			$this->_parameterName(
 				join '/', ( map {
-					$_->nodeProperty('instanceId') ?
+					(defined $_->nodeProperty('instanceId')) ?
 						$_->nodeName . '['.$_->nodeProperty('instanceId').']':
 						$_->nodeName
 				} $this->_selectParents, $this )
@@ -43,7 +43,7 @@
 	$target ||= $this;
 	
 	my $query = $this->document->nodeProperty('query') or die new IMPL::InvalidOperationException("Failed to get a CGI query from the document");
-	my $hFile = $query->upload($this->parameterName) or $query->cgi_error ? die new IMPL::IOException("Failed to open the uploaded file",$query->cgi_error) : return;
+	my $hFile = $query->upload($this->parameterName) or die new IMPL::IOException("Failed to open the uploaded file",$query->cgi_error,$this->parameterName,$this->nodeProperty('instanceId'));
 			
 	my ($hTemp,$tempFileName) = tempfile();
 	binmode($hTemp);
@@ -54,7 +54,7 @@
 	seek $hTemp, 0,0;
 	{
 		local $_ = $tempFileName;
-		&$sub($this,$tempFileName,$hTemp);
+		$sub->($this,$tempFileName,$hTemp);
 	}
 }