diff Lib/IMPL/Web/Application/ControllerUnit.pm @ 173:aaab45153411

minor bugfixes
author sourcer
date Wed, 14 Sep 2011 18:59:01 +0400
parents 068acfe903c3
children d1676be8afcc
line wrap: on
line diff
--- a/Lib/IMPL/Web/Application/ControllerUnit.pm	Mon Jun 20 23:42:44 2011 +0400
+++ b/Lib/IMPL/Web/Application/ControllerUnit.pm	Wed Sep 14 18:59:01 2011 +0400
@@ -13,7 +13,9 @@
 	CONTROLLER_METHODS => 'controller_methods',
 	STATE_CORRECT => 'correct',
 	STATE_NEW => 'new',
-	STATE_INVALID => 'invalid'
+	STATE_INVALID => 'invalid',
+	TTYPE_FORM => 'form',
+	TTYPE_TRANS => 'tran'
 };
 
 BEGIN {
@@ -58,6 +60,7 @@
 		
 		$info->{wrapper} = 'TransactionWrapper';
 		$info->{method} ||= $method;
+		$info->{context}{transactionType} = TTYPE_TRANS;
 		$self->class_data(CONTROLLER_METHODS)->{$method} = $info;
 	}
 }
@@ -71,11 +74,13 @@
 			$self->class_data(CONTROLLER_METHODS)->{$method} = {
 				wrapper => 'FormWrapper',
 				schema => $info,
-				method => $method
+				method => $method,
+				context => { transactionType => TTYPE_FORM }
 			};
 		} elsif (ref $info eq 'HASH') {
 			$info->{wrapper} = 'FormWrapper';
 			$info->{method} ||= $method;
+			$info->{context}{transactionType} = TTYPE_FORM;
 			
 			$self->class_data(CONTROLLER_METHODS)->{$method} = $info;
 		} else {
@@ -88,6 +93,9 @@
 	my ($self,$method,$action) = @_;
 	
 	if (my $methodInfo = $self->class_data(CONTROLLER_METHODS)->{$method}) {
+		if (my $ctx = $methodInfo->{context}) {
+			$action->context->{$_} = $ctx->{$_} foreach keys %$ctx;
+		}
 		if (my $wrapper = $methodInfo->{wrapper}) {
 			return $self->$wrapper($method,$action,$methodInfo);
 		} else {