diff Lib/IMPL/Web/Application/ControllerUnit.pm @ 170:b88b7fe60aa3

refactoring
author sourcer
date Tue, 24 May 2011 01:11:16 +0400
parents 4267a2ac3d46
children 59e5fcb59d86
line wrap: on
line diff
--- a/Lib/IMPL/Web/Application/ControllerUnit.pm	Tue May 17 00:04:28 2011 +0400
+++ b/Lib/IMPL/Web/Application/ControllerUnit.pm	Tue May 24 01:11:16 2011 +0400
@@ -26,10 +26,12 @@
 	public property formErrors => prop_get | owner_set;
 }
 
-my %publicProps = map {$_->Name , 1} __PACKAGE__->get_meta(typeof IMPL::Class::PropertyInfo); 
+my %publicProps = map {$_->Name , 1} __PACKAGE__->get_meta(typeof IMPL::Class::PropertyInfo);
 
 __PACKAGE__->class_data(CONTROLLER_METHODS,{});
 
+our @schemaInc;
+
 sub CTOR {
 	my ($this,$action,$args) = @_;
 	
@@ -185,14 +187,31 @@
 
 sub loadSchema {
 	my ($self,$name) = @_;
+	
+	foreach my $path (map File::Spec->catfile($_,$name) ,@schemaInc) {
+		return IMPL::DOM::Schema->LoadSchema($path) if -f $path;
+	}
 
-	if (-f $name) {
-		return IMPL::DOM::Schema->LoadSchema($name);
-	} else {
-		my ($vol,$dir,$file) = File::Spec->splitpath( Class::Inspector->resolved_filename(ref $self || $self) );
+	die new IMPL::Exception("A schema isn't found", $name);
+}
+
+sub unitSchema {
+	my ($self) = @_;
+	
+	my $class = ref $self || $self;
+	
+	my @parts = split(/:+/, $class);
+	
+	my $file = pop @parts;
+	$file = "${file}.schema.xml";
+	
+	foreach my $inc ( @schemaInc ) {
+		my $path = File::Spec->catfile($inc,@parts,$file);
 		
-		return IMPL::DOM::Schema->LoadSchema(File::Spec->catfile($vol,$dir,$name));
+		return IMPL::DOM::Schema->LoadSchema($path) if -f $path;
 	}
+	
+	return undef;
 }
 
 sub discover {