diff Lib/IMPL/Web/QueryHandler/PageFormat.pm @ 116:1722ca51537c

minor changes. Auth no more throws an exception when fails
author wizard
date Mon, 31 May 2010 08:30:39 +0400
parents 0e72ad99eef7
children 92c850d0bdb9
line wrap: on
line diff
--- a/Lib/IMPL/Web/QueryHandler/PageFormat.pm	Wed May 26 02:32:22 2010 +0400
+++ b/Lib/IMPL/Web/QueryHandler/PageFormat.pm	Mon May 31 08:30:39 2010 +0400
@@ -13,6 +13,7 @@
 	public property templatesCharset => prop_all;
 	public property templatesBase => prop_all;
 	public property defaultTarget => prop_all;
+	public property pathinfoPrefix => prop_all;
 }
 
 sub CTOR {
@@ -31,17 +32,22 @@
 		$this->templatesBase($ENV{DOCUMENT_ROOT}) unless $this->templatesBase;
 		
 		my $pathInfo = $ENV{PATH_INFO};
-		local $ENV{PATH_INFO} = $pathInfo || $this->defaultTarget; 
+		my $prefixRoot = "";
+		if (my $rx = $this->pathinfoPrefix) {
+			$pathInfo =~ s/($rx)//;
+			$prefixRoot = $1 if $1;
+		}
+		local $ENV{PATH_INFO} = $pathInfo || $this->defaultTarget;
 		
 		my @path = split /\//, ($ENV{PATH_INFO} || '') or die new IMPL::Exception("PATH_INFO is empty and no defaultTarget specified" );
 		
 		$doc->LoadFile ( File::Spec->catfile($this->templatesBase,@path), $this->templatesCharset );
 		$doc->AddVar( result => $nextHandler->() );
-		$doc->AddVar( absoluteUrl => sub { "/$_[0]" } );
+		$doc->AddVar( absoluteUrl => sub { "$prefixRoot/$_[0]" } );
 		{
 			local $@;
-			$doc->AddVar( user => eval { IMPL::Security::Context->current->principal; } );
-			$doc->AddVar( session => eval { IMPL::Security::Context->current; } );
+			$doc->AddVar( user => IMPL::Security::Context->current->principal );
+			$doc->AddVar( session => IMPL::Security::Context->current );
 			warn $@ if $@;
 		}