Mercurial > pub > Impl
comparison Lib/IMPL/Web/Application/Resource.pm @ 333:cd6409f66a5f
small fixes, request environment is deprecated
| author | cin |
|---|---|
| date | Tue, 11 Jun 2013 20:22:52 +0400 |
| parents | 04a093f0a5a6 |
| children | 71221d79e6b4 |
comparison
equal
deleted
inserted
replaced
| 332:04a093f0a5a6 | 333:cd6409f66a5f |
|---|---|
| 1 package IMPL::Web::Application::Resource; | 1 package IMPL::Web::Application::Resource; |
| 2 use strict; | 2 use strict; |
| 3 | 3 |
| 4 use URI; | 4 use URI; |
| 5 use Carp qw(carp); | |
| 5 use IMPL::Const qw(:prop); | 6 use IMPL::Const qw(:prop); |
| 6 use IMPL::declare { | 7 use IMPL::declare { |
| 7 require => { | 8 require => { |
| 8 ViewResult => 'IMPL::Web::ViewResult', | 9 ViewResult => 'IMPL::Web::ViewResult', |
| 9 Exception => 'IMPL::Exception', | 10 Exception => 'IMPL::Exception', |
| 33 die ArgumentException->new( id => 'A resource identifier is required' ) | 34 die ArgumentException->new( id => 'A resource identifier is required' ) |
| 34 unless $args{id}; | 35 unless $args{id}; |
| 35 die ArgumentException->new( contract => 'A contract is required' ) | 36 die ArgumentException->new( contract => 'A contract is required' ) |
| 36 unless $args{contract}; | 37 unless $args{contract}; |
| 37 | 38 |
| 38 $this->request($args{action}) | 39 $this->request($args{request}) |
| 39 or die ArgumentException->new(request => 'A request object must be specified'); | 40 or die ArgumentException->new(request => 'A request object must be specified'); |
| 40 $this->parent( $args{parent} ); | 41 $this->parent( $args{parent} ); |
| 41 $this->model( $args{model} ); | 42 $this->model( $args{model} ); |
| 42 $this->id( $args{id} ); | 43 $this->id( $args{id} ); |
| 43 $this->contract( $args{contract} ); | 44 $this->contract( $args{contract} ); |
| 44 $this->application( $args{action}{application} ); | 45 $this->application( $args{request}->application ); |
| 45 | 46 |
| 46 # если расположение явно не указано, то оно вычисляется автоматически, | 47 # если расположение явно не указано, то оно вычисляется автоматически, |
| 47 # либо остается не заданным | 48 # либо остается не заданным |
| 48 $this->location( $args{location} | 49 $this->location( $args{location} |
| 49 || eval { $this->parent->location->Child( $this->id ) } ); | 50 || eval { $this->parent->location->Child( $this->id ) } ); |
| 68 # это свойство специфично только для REST приложений. | 69 # это свойство специфично только для REST приложений. |
| 69 # сохранение текущего ресурса не повлечет за собой существенных расходов, | 70 # сохранение текущего ресурса не повлечет за собой существенных расходов, |
| 70 # т.к. они просто освободятся несколько позже. | 71 # т.к. они просто освободятся несколько позже. |
| 71 if ( not $request->context->{resource} ) { | 72 if ( not $request->context->{resource} ) { |
| 72 $request->context->{resource} = $this; | 73 $request->context->{resource} = $this; |
| 73 $request->context->{environment} = sub { $this->PrepareEnvironment() }; | 74 $request->context->{environment} = sub { |
| 75 carp "using request environment is deprecated"; | |
| 76 $this->PrepareEnvironment() | |
| 77 }; | |
| 74 } | 78 } |
| 75 | 79 |
| 76 return _InvokeDelegate( $operation, $this, $request ); | 80 return _InvokeDelegate( $operation, $this, $request ); |
| 77 } | 81 } |
| 78 | 82 |
