annotate Lib/IMPL/Web/Application/ResourceBase.pm @ 391:2287c72f303a

code cleanup
author cin
date Thu, 13 Feb 2014 20:17:22 +0400
parents e12c14177848
children 2c14f66efa08
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
372
e12c14177848 refactoring web resources model, implementing new simplified model
cin
parents: 359
diff changeset
1 package IMPL::Web::Application::ResourceBase;
229
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
2 use strict;
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
3
256
32aceba4ee6d corrected ViewHandlers to handle cookies and headers.
sergey
parents: 255
diff changeset
4 use URI;
334
71221d79e6b4 removing web resources contracts
cin
parents: 333
diff changeset
5 use Carp qw(carp);
71221d79e6b4 removing web resources contracts
cin
parents: 333
diff changeset
6 use IMPL::lang qw(:hash :base);
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
7 use IMPL::Const qw(:prop);
229
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
8 use IMPL::declare {
332
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
9 require => {
372
e12c14177848 refactoring web resources model, implementing new simplified model
cin
parents: 359
diff changeset
10
332
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
11 Exception => 'IMPL::Exception',
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
12 ArgumentException => '-IMPL::InvalidArgumentException',
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
13 OperationException => '-IMPL::InvalidOperationException',
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
14 NotAllowedException => 'IMPL::Web::NotAllowedException',
372
e12c14177848 refactoring web resources model, implementing new simplified model
cin
parents: 359
diff changeset
15
332
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
16 },
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
17 base => [
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
18 'IMPL::Object' => undef,
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
19 'IMPL::Web::Application::ResourceInterface' => undef
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
20 ],
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
21 props => [
359
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
22 request => PROP_RO,
332
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
23 application => PROP_RO,
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
24 parent => PROP_RO,
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
25 model => PROP_RO,
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
26 id => PROP_RO,
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
27 location => PROP_RO,
359
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
28 role => PROP_RO | PROP_LIST
332
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
29 ]
229
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
30 };
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
31
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
32 sub CTOR {
332
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
33 my ( $this, %args ) = @_;
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
34
334
71221d79e6b4 removing web resources contracts
cin
parents: 333
diff changeset
35 die ArgumentException->new(request => 'A request object must be specified')
71221d79e6b4 removing web resources contracts
cin
parents: 333
diff changeset
36 unless $args{request};
71221d79e6b4 removing web resources contracts
cin
parents: 333
diff changeset
37
71221d79e6b4 removing web resources contracts
cin
parents: 333
diff changeset
38 $this->request( $args{request} );
332
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
39 $this->parent( $args{parent} );
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
40 $this->model( $args{model} );
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
41 $this->id( $args{id} );
333
cd6409f66a5f small fixes, request environment is deprecated
cin
parents: 332
diff changeset
42 $this->application( $args{request}->application );
334
71221d79e6b4 removing web resources contracts
cin
parents: 333
diff changeset
43
268
4abda21186cd *refactoring IMPL::Web: added 'application' property to resources
cin
parents: 256
diff changeset
44 # если расположение явно не указано, то оно вычисляется автоматически,
4abda21186cd *refactoring IMPL::Web: added 'application' property to resources
cin
parents: 256
diff changeset
45 # либо остается не заданным
332
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
46 $this->location( $args{location}
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
47 || eval { $this->parent->location->Child( $this->id ) } );
359
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
48
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
49 if (my $role = $args{role}) {
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
50 if (ref($role) eq 'ARRAY') {
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
51 $this->role($role);
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
52 } elsif (not ref($role)) {
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
53 $this->role(split(/\s+/, $role));
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
54 } else {
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
55 die ArgumentException->new( role => 'A invalid value is provided, expected ARRAY or SCALAR');
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
56 }
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
57 }
229
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
58 }
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
59
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
60 sub InvokeHttpVerb {
332
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
61 my ( $this, $verb ) = @_;
268
4abda21186cd *refactoring IMPL::Web: added 'application' property to resources
cin
parents: 256
diff changeset
62
334
71221d79e6b4 removing web resources contracts
cin
parents: 333
diff changeset
63 my $operation = $this->verbs->{ lc($verb) };
229
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
64
332
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
65 die NotAllowedException->new(
335
e8be9062ecf2 improved resource classes, contracts are deprecated
cin
parents: 334
diff changeset
66 allow => join( ',', $this->GetAllowedMethods ) )
332
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
67 unless $operation;
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
68
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
69 $this->AccessCheck($verb);
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
70 my $request = $this->request;
229
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
71
268
4abda21186cd *refactoring IMPL::Web: added 'application' property to resources
cin
parents: 256
diff changeset
72 # в случае, когда один ресурс вызывает HTTP метод другого ресурса, нужно
4abda21186cd *refactoring IMPL::Web: added 'application' property to resources
cin
parents: 256
diff changeset
73 # сохранить оригинальный resourceLocation
332
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
74 $request->context->{resourceLocation} ||= $this->location;
268
4abda21186cd *refactoring IMPL::Web: added 'application' property to resources
cin
parents: 256
diff changeset
75
332
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
76 # это свойство специфично только для REST приложений.
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
77 # сохранение текущего ресурса не повлечет за собой существенных расходов,
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
78 # т.к. они просто освободятся несколько позже.
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
79 if ( not $request->context->{resource} ) {
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
80 $request->context->{resource} = $this;
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
81 }
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
82
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
83 return _InvokeDelegate( $operation, $this, $request );
229
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
84 }
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
85
357
ec58c47edb52 web security: code cleanup, refactoring
cin
parents: 335
diff changeset
86 sub security {
ec58c47edb52 web security: code cleanup, refactoring
cin
parents: 335
diff changeset
87 shift->request->security
ec58c47edb52 web security: code cleanup, refactoring
cin
parents: 335
diff changeset
88 }
ec58c47edb52 web security: code cleanup, refactoring
cin
parents: 335
diff changeset
89
ec58c47edb52 web security: code cleanup, refactoring
cin
parents: 335
diff changeset
90 sub verbs {
ec58c47edb52 web security: code cleanup, refactoring
cin
parents: 335
diff changeset
91 {} # возвращаем пстой список операций
ec58c47edb52 web security: code cleanup, refactoring
cin
parents: 335
diff changeset
92 }
ec58c47edb52 web security: code cleanup, refactoring
cin
parents: 335
diff changeset
93
335
e8be9062ecf2 improved resource classes, contracts are deprecated
cin
parents: 334
diff changeset
94 sub GetAllowedMethods {
372
e12c14177848 refactoring web resources model, implementing new simplified model
cin
parents: 359
diff changeset
95 map( uc, keys %{ shift->verbs } );
335
e8be9062ecf2 improved resource classes, contracts are deprecated
cin
parents: 334
diff changeset
96 }
e8be9062ecf2 improved resource classes, contracts are deprecated
cin
parents: 334
diff changeset
97
330
fe725fad2d90 Added access checking to web resources
sergey
parents: 285
diff changeset
98 sub AccessCheck {
332
04a093f0a5a6 IMPL::Web::Application refactoring: resources are created per client request
cin
parents: 330
diff changeset
99
330
fe725fad2d90 Added access checking to web resources
sergey
parents: 285
diff changeset
100 }
fe725fad2d90 Added access checking to web resources
sergey
parents: 285
diff changeset
101
359
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
102 sub Seek {
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
103 my ($this, $role) = @_;
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
104
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
105 my @roles;
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
106
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
107 if (ref($role) eq 'ARRAY') {
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
108 @roles = @{$role};
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
109 } elsif (not ref($role)) {
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
110 @roles = split(/\s+/, $role);
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
111 } else {
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
112 die ArgumentException->new( role => 'A invalid value is provided, expected ARRAY or SCALAR');
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
113 }
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
114
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
115
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
116 for(my $r = $this; $r; $r = $r->parent) {
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
117 return $r if $r->HasRole(@roles);
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
118 }
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
119 return;
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
120 }
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
121
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
122 sub HasRole {
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
123 my ($this, @roles) = @_;
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
124 my %cache = map { $_, 1 } @{$this->role};
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
125 return scalar(grep not($cache{$_}), @roles) ? 0 : 1;
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
126 }
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
127
372
e12c14177848 refactoring web resources model, implementing new simplified model
cin
parents: 359
diff changeset
128 sub _InvokeDelegate {
e12c14177848 refactoring web resources model, implementing new simplified model
cin
parents: 359
diff changeset
129 my $delegate = shift;
e12c14177848 refactoring web resources model, implementing new simplified model
cin
parents: 359
diff changeset
130
e12c14177848 refactoring web resources model, implementing new simplified model
cin
parents: 359
diff changeset
131 return $delegate->(@_) if ref $delegate eq 'CODE';
e12c14177848 refactoring web resources model, implementing new simplified model
cin
parents: 359
diff changeset
132 return $delegate->Invoke(@_) if eval { $delegate->can('Invoke') };
e12c14177848 refactoring web resources model, implementing new simplified model
cin
parents: 359
diff changeset
133 }
e12c14177848 refactoring web resources model, implementing new simplified model
cin
parents: 359
diff changeset
134
229
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
135 1;
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
136
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
137 __END__
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
138
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
139 =pod
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
140
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
141 =head1 NAME
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
142
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
143 C<IMPL::Web::Application::Resource> - Web-ресурс.
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
144
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
145 =head1 SYNOPSIS
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
146
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
147 Класс для внутреннего использования. Объединяет в себе контракт и модель данных.
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
148 Основная задача - обработать поступающий от контроллера запрос на вызов C<HTTP>
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
149 метода.
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
150
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
151 Экземпляры данного класса передаются в качестве параметров делегатам
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
152 осуществляющим привязку к модели в C<IMPL::Web::Application::ResourceContract>
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
153 и C<IMPL::Web::Application::OperationContract>.
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
154
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
155 =head1 DESCRIPTION
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
156
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
157 Весь функционал ресурса, поддерживаемые им C<HTTP> методы определяются
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
158 контрактом. Однако можно реализовывать ресурсы, которые не имеют контракта
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
159 или он отличается от того, что предоставляется стандартно
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
160 C<IMPL::Web::Application::ResourceContract>.
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
161
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
162 Каждый ресурс является контейнером, тоесть позволяет получить дочерний ресурс
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
163 по идентифифкатору, если таковой имеется, тоесть ресурс, у которого нет дочерних
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
164 ресурсов на самом деле рассматривается как пустой контейнер.
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
165
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
166 С ресурсом непосредственно взаимодействует котроллер запросов
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
167 C<IMPL::Web::Handler::RestController>, вызывая два метода.
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
168
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
169 =over
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
170
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
171 =item * C<FetchChildResource($childId)>
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
172
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
173 Данный метод возвращает дочерний ресурс, соответствующий C<$childId>.
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
174 Текущая реализация использует метод C<FindChildResourceInfo> контракта текущего
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
175 ресурса, после чего создает дочерний ресурс.
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
176
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
177 Если дочерний ресурс не найден, вызывается исключение
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
178 C<IMPL::Web::NotFoundException>.
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
179
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
180 =item * C<InvokeHttpVerb($verb,$action)>
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
181
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
182 Обрабатывает запрос к ресурсу. Для этого используется контракт ресурса, в
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
183 нем выбирается соответсвующий C<IMPL::Web::Application::OperationContract>.
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
184 Затем найденный контракт для указанной операции используется для обработки
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
185 запроса.
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
186
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
187 =back
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
188
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
189 Если объект реализует два вышеуказанных метода, он является веб-ресурсом, а
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
190 детали его реализации, котнракт и прочее уже не важно, поэтому можно реализовать
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
191 собственный класс ресурса, например унаследованный от
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
192 C<IMPL::Web::Application::CustomResource>.
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
193
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
194 =head1 MEMBERS
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
195
357
ec58c47edb52 web security: code cleanup, refactoring
cin
parents: 335
diff changeset
196 =head2 C<[get]request>
ec58c47edb52 web security: code cleanup, refactoring
cin
parents: 335
diff changeset
197
ec58c47edb52 web security: code cleanup, refactoring
cin
parents: 335
diff changeset
198 Объект C<IMPL::Web::Application::Action> представляющий запрос к серверу.
ec58c47edb52 web security: code cleanup, refactoring
cin
parents: 335
diff changeset
199
268
4abda21186cd *refactoring IMPL::Web: added 'application' property to resources
cin
parents: 256
diff changeset
200 =head2 C<[get]application>
4abda21186cd *refactoring IMPL::Web: added 'application' property to resources
cin
parents: 256
diff changeset
201
357
ec58c47edb52 web security: code cleanup, refactoring
cin
parents: 335
diff changeset
202 Ссылка на приложение, к которому относится данный ресурс. Получается
ec58c47edb52 web security: code cleanup, refactoring
cin
parents: 335
diff changeset
203 автоматически из объекта запроса.
268
4abda21186cd *refactoring IMPL::Web: added 'application' property to resources
cin
parents: 256
diff changeset
204
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
205 =head2 C<[get]contract>
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
206
248
814d755e5d12 Minor fixes
sergey
parents: 245
diff changeset
207 Обязательное свойство для ресурса, ссылается, на контракт, соответствующий
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
208 данному ресурсу, используется для выполнения C<HTTP> методов и получения
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
209 дочерних ресурсов.
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
210
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
211 =head2 C<[get]id>
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
212
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
213 Обязательное свойство ресурса, идентифицирует его в родительском контейнере,
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
214 для корневого ресурса может иметь произвольное значение.
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
215
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
216 =head2 C<[get]parent>
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
217
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
218 Ссылка на родительский ресурс, для корневого ресурса не определена.
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
219
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
220 =head2 C<[get]model>
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
221
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
222 Ссылка на объект предметной области, представляемый данным ресурсом. Данное
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
223 свойство не является обязательным и может быть не задано.
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
224
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
225 =head2 C<[get]location>
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
226
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
227 Объект типа C<IMPL::Web::AutoLocator> или аналогичный описывающий адрес текущего
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
228 ресурса, может быть как явно передан при создании ресурса, так и вычислен
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
229 автоматически (только для ресурсов имеющих родителя). Следует заметить, что
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
230 адрес ресурса не содержит параметров запроса, а только путь.
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
231
359
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
232 =head2 C<[get,list]role>
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
233
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
234 Список ролей ресурса. Роль это условный маркер, который позволяет определить
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
235 функции выполняемые ресурсом, например контейнер, профиль пользователя и т.п.
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
236
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
237 Используется при построении цепочек навигации, а также при поиске с использованием
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
238 метода C<seek>.
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
239
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
240 =head2 C<seek($role)>
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
241
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
242 Ищет ресурс в цепочке родителей (включая сам ресурс) с подходящими ролями.
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
243
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
244 Роли могут быть переданы в виде массива или строки, где роли разделены пробелами
833e663796c4 TTView: added view variable to pass rendering context between controls
sergey
parents: 357
diff changeset
245
268
4abda21186cd *refactoring IMPL::Web: added 'application' property to resources
cin
parents: 256
diff changeset
246 =head2 C<[get]FetchChildResource($id)>
4abda21186cd *refactoring IMPL::Web: added 'application' property to resources
cin
parents: 256
diff changeset
247
4abda21186cd *refactoring IMPL::Web: added 'application' property to resources
cin
parents: 256
diff changeset
248 Возвращает дочерний ресурс, по его идентификатору.
4abda21186cd *refactoring IMPL::Web: added 'application' property to resources
cin
parents: 256
diff changeset
249
4abda21186cd *refactoring IMPL::Web: added 'application' property to resources
cin
parents: 256
diff changeset
250 Данная реализация использует контракт текущего ресурса для поиска информации о
4abda21186cd *refactoring IMPL::Web: added 'application' property to resources
cin
parents: 256
diff changeset
251 дочернем ресурсе C<< $this->contract->FindChildResourceInfo($id) >>.
4abda21186cd *refactoring IMPL::Web: added 'application' property to resources
cin
parents: 256
diff changeset
252
4abda21186cd *refactoring IMPL::Web: added 'application' property to resources
cin
parents: 256
diff changeset
253 Затем осуществляется привязка к моделе, тоесть, выполняется делегат, для
4abda21186cd *refactoring IMPL::Web: added 'application' property to resources
cin
parents: 256
diff changeset
254 получения модели дочернего ресурса, а затем осуществляется привязка к контракту,
4abda21186cd *refactoring IMPL::Web: added 'application' property to resources
cin
parents: 256
diff changeset
255 при этом в делегат, который должен вернуть контракт дочернего ресурса передаются
4abda21186cd *refactoring IMPL::Web: added 'application' property to resources
cin
parents: 256
diff changeset
256 текущий ресурc и модель дочернего ресурса.
4abda21186cd *refactoring IMPL::Web: added 'application' property to resources
cin
parents: 256
diff changeset
257
229
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
258 =cut