comparison 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
comparison
equal deleted inserted replaced
115:5edc2ac5231c 116:1722ca51537c
11 11
12 BEGIN { 12 BEGIN {
13 public property templatesCharset => prop_all; 13 public property templatesCharset => prop_all;
14 public property templatesBase => prop_all; 14 public property templatesBase => prop_all;
15 public property defaultTarget => prop_all; 15 public property defaultTarget => prop_all;
16 public property pathinfoPrefix => prop_all;
16 } 17 }
17 18
18 sub CTOR { 19 sub CTOR {
19 my ($this) = @_; 20 my ($this) = @_;
20 21
29 try { 30 try {
30 31
31 $this->templatesBase($ENV{DOCUMENT_ROOT}) unless $this->templatesBase; 32 $this->templatesBase($ENV{DOCUMENT_ROOT}) unless $this->templatesBase;
32 33
33 my $pathInfo = $ENV{PATH_INFO}; 34 my $pathInfo = $ENV{PATH_INFO};
34 local $ENV{PATH_INFO} = $pathInfo || $this->defaultTarget; 35 my $prefixRoot = "";
36 if (my $rx = $this->pathinfoPrefix) {
37 $pathInfo =~ s/($rx)//;
38 $prefixRoot = $1 if $1;
39 }
40 local $ENV{PATH_INFO} = $pathInfo || $this->defaultTarget;
35 41
36 my @path = split /\//, ($ENV{PATH_INFO} || '') or die new IMPL::Exception("PATH_INFO is empty and no defaultTarget specified" ); 42 my @path = split /\//, ($ENV{PATH_INFO} || '') or die new IMPL::Exception("PATH_INFO is empty and no defaultTarget specified" );
37 43
38 $doc->LoadFile ( File::Spec->catfile($this->templatesBase,@path), $this->templatesCharset ); 44 $doc->LoadFile ( File::Spec->catfile($this->templatesBase,@path), $this->templatesCharset );
39 $doc->AddVar( result => $nextHandler->() ); 45 $doc->AddVar( result => $nextHandler->() );
40 $doc->AddVar( absoluteUrl => sub { "/$_[0]" } ); 46 $doc->AddVar( absoluteUrl => sub { "$prefixRoot/$_[0]" } );
41 { 47 {
42 local $@; 48 local $@;
43 $doc->AddVar( user => eval { IMPL::Security::Context->current->principal; } ); 49 $doc->AddVar( user => IMPL::Security::Context->current->principal );
44 $doc->AddVar( session => eval { IMPL::Security::Context->current; } ); 50 $doc->AddVar( session => IMPL::Security::Context->current );
45 warn $@ if $@; 51 warn $@ if $@;
46 } 52 }
47 53
48 $action->response->contentType('text/html'); 54 $action->response->contentType('text/html');
49 my $hOut = $action->response->streamBody; 55 my $hOut = $action->response->streamBody;