comparison Lib/IMPL/Web/QueryHandler/PageFormat.pm @ 97:964587c5183c

Added SecureCall to Web QueryHandlers stack many bug fixes to Security and Web Application modules
author wizard
date Tue, 04 May 2010 04:04:37 +0400
parents 9d24db321029
children 0e72ad99eef7
comparison
equal deleted inserted replaced
96:4c55aed00ff2 97:964587c5183c
3 3
4 __PACKAGE__->PassThroughArgs; 4 __PACKAGE__->PassThroughArgs;
5 5
6 use IMPL::Class::Property; 6 use IMPL::Class::Property;
7 use IMPL::Web::TT::Document; 7 use IMPL::Web::TT::Document;
8 use IMPL::Security::Context;
8 use File::Spec; 9 use File::Spec;
9 use Error qw(:try); 10 use Error qw(:try);
10 11
11 BEGIN { 12 BEGIN {
12 public property templatesCharset => prop_all; 13 public property templatesCharset => prop_all;
13 public property templatesBase => prop_all; 14 public property templatesBase => prop_all;
15 public property defaultTarget => prop_all;
14 } 16 }
15 17
16 sub CTOR { 18 sub CTOR {
17 my ($this) = @_; 19 my ($this) = @_;
18 20
19 $this->templatesCharset('utf-8') unless $this->templatesCharset; 21 $this->templatesCharset('utf-8') unless $this->templatesCharset;
20 $this->templatesBase('.') unless $this->templatesBase;
21 } 22 }
22 23
23 sub Process { 24 sub Process {
24 my ($this,$action,$nextHandler) = @_; 25 my ($this,$action,$nextHandler) = @_;
25 26
26 my $doc = new IMPL::Web::TT::Document(); 27 my $doc = new IMPL::Web::TT::Document();
27 28
28 try { 29 try {
29 my @path = split /\//, $ENV{PATH_TRANSLATED}; 30
31 $this->templatesBase($ENV{DOCUMENT_ROOT}) unless $this->templatesBase;
32
33 my $pathInfo = $ENV{PATH_INFO};
34 local $ENV{PATH_INFO} = $pathInfo || $this->defaultTarget;
35
36 my @path = split /\//, ($ENV{PATH_INFO} || '') or die new IMPL::Exception("PATH_INFO is empty and no defaultTarget specified" );
30 37
31 $doc->LoadFile ( File::Spec->catfile($this->templatesBase,@path), $this->templatesCharset ); 38 $doc->LoadFile ( File::Spec->catfile($this->templatesBase,@path), $this->templatesCharset );
39 $doc->AddVar( result => $nextHandler->() );
40 {
41 local $@;
42 $doc->AddVar( user => eval { IMPL::Security::Context->current->principal; } );
43 $doc->AddVar( session => eval { IMPL::Security::Context->current; } );
44 warn $@ if $@;
45 }
32 46
33 $action->response->contentType('text/html'); 47 $action->response->contentType('text/html');
34 my $hOut = $action->response->streamBody; 48 my $hOut = $action->response->streamBody;
35
36 print $hOut $doc->Render(); 49 print $hOut $doc->Render();
37 } finally { 50 } finally {
38 $doc->Dispose; 51 $doc->Dispose;
39 }; 52 };
40 } 53 }