Mercurial > pub > Impl
diff Lib/IMPL/Web/Handler/View.pm @ 359:833e663796c4
TTView: added view variable to pass rendering context between controls
TTView: display function renamed to display_for
WebResource: resources now marked with roles for searching a desired resource by a role in the resource chain
author | sergey |
---|---|
date | Mon, 25 Nov 2013 02:19:31 +0400 |
parents | 9330835535b9 |
children | d5c8b955bf8d |
line wrap: on
line diff
--- a/Lib/IMPL/Web/Handler/View.pm Mon Nov 18 01:25:35 2013 +0400 +++ b/Lib/IMPL/Web/Handler/View.pm Mon Nov 25 02:19:31 2013 +0400 @@ -10,7 +10,8 @@ Factory => 'IMPL::Web::View::ObjectFactory', HttpResponse => 'IMPL::Web::HttpResponse', Loader => 'IMPL::Code::Loader', - ViewResult => '-IMPL::Web::ViewResult' + ViewResult => '-IMPL::Web::ViewResult', + Security => 'IMPL::Security' }, base => [ 'IMPL::Object' => undef, @@ -40,24 +41,25 @@ my $result = $next ? $next->($action) : undef; - my ($model,$view,$template); + my ($model,$template); if( ref $result and eval { $result->isa(ViewResult) } ) { $model = $result->model; - $view = $result; $template = $result->template; } else { $model = $result; - $view = ViewResult->new(model => $model); + $result = ViewResult->new(model => $model); } my $vars = { - view => $view, + result => $result, request => sub { $action }, app => $action->application, - context => $action->context, - env => _cached($action->context->{environment}), location => $action->context->{resourceLocation}, - layout => $this->layout + resource => $action->context->{resource}, + layout => $this->layout, + document => {}, + session => sub { Security->context }, + user => sub { Security->principal } }; my %responseParams = ( @@ -70,25 +72,15 @@ ) ); - $responseParams{status} = $view->status if $view->status; - $responseParams{cookies} = $view->cookies if ref $view->cookies eq 'HASH'; - $responseParams{headers} = $view->headers if ref $view->headers eq 'HASH'; + $responseParams{status} = $result->status if $result->status; + $responseParams{cookies} = $result->cookies if ref $result->cookies eq 'HASH'; + $responseParams{headers} = $result->headers if ref $result->headers eq 'HASH'; return HttpResponse->new( %responseParams ); } -sub _cached { - my $arg = shift; - - return $arg unless ref $arg eq 'CODE'; - - return sub { - ref $arg eq 'CODE' ? $arg = &$arg() : $arg; - } -} - sub SelectView { my ($this,$action) = @_;