diff Lib/IMPL/Web/Application/ControllerUnit.pm @ 172:068acfe903c3

corrected schema resolution mechanism
author sourcer
date Mon, 20 Jun 2011 23:42:44 +0400
parents 59e5fcb59d86
children aaab45153411
line wrap: on
line diff
--- a/Lib/IMPL/Web/Application/ControllerUnit.pm	Mon Jun 06 03:30:36 2011 +0400
+++ b/Lib/IMPL/Web/Application/ControllerUnit.pm	Mon Jun 20 23:42:44 2011 +0400
@@ -57,6 +57,7 @@
 		}
 		
 		$info->{wrapper} = 'TransactionWrapper';
+		$info->{method} ||= $method;
 		$self->class_data(CONTROLLER_METHODS)->{$method} = $info;
 	}
 }
@@ -69,10 +70,12 @@
 		if ( not ref $info ) {
 			$self->class_data(CONTROLLER_METHODS)->{$method} = {
 				wrapper => 'FormWrapper',
-				schema => $info
+				schema => $info,
+				method => $method
 			};
 		} elsif (ref $info eq 'HASH') {
 			$info->{wrapper} = 'FormWrapper';
+			$info->{method} ||= $method;
 			
 			$self->class_data(CONTROLLER_METHODS)->{$method} = $info;
 		} else {
@@ -129,7 +132,8 @@
 	my ($self,$method,$action,$methodInfo) = @_;
 	
 	my $unit = $self->new($action);
-	return $unit->$method($unit->MakeParams($methodInfo));
+	my $handler = $methodInfo->{method};
+	return $unit->$handler($unit->MakeParams($methodInfo));
 }
 
 sub FormWrapper {
@@ -150,6 +154,8 @@
 		$form
 	);
 	
+	my $handler = $methodInfo->{method};
+	
 	$result{formName} = $form;
 	$result{formSchema} = $schema;
 	
@@ -163,7 +169,7 @@
 			my $unit = $self->new($action,\%result);
 			
 			eval {
-				$result{result} = $unit->$method($unit->MakeParams($methodInfo));
+				$result{result} = $unit->$handler($unit->MakeParams($methodInfo));
 			};
 			if (my $err = $@) {
 				$result{state} = STATE_INVALID;
@@ -182,7 +188,8 @@
 			$result{formData} = $transform->Transform($action->query);
 		}
 		
-		$result{formErrors} = $transform->Errors->as_list;
+		# ignore errors for new forms
+		#$result{formErrors} = $transform->Errors->as_list;
 		$result{state} = STATE_NEW;
 	}