annotate Lib/IMPL/Web/Application/Action.pm @ 54:f4e045e47770

commit
author wizard@linux-odin.local
date Tue, 02 Mar 2010 20:15:57 +0300
parents 15d720913562
children 609b59c9f03c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
52
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
1 package IMPL::Web::Application::Action;
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
2
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
3 use base qw(IMPL::Object);
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
4
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
5 use IMPL::Class::Property;
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
6
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
7 BEGIN {
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
8 public property application => prop_get | owner_set;
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
9 public property request => prop_get | owner_set;
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
10 public property response => prop_get | owner_set;
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
11 public property code => prop_get | owner_set;
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
12 public property chainHandlers => prop_get | owner_set | prop_list;
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
13 }
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
14
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
15 1;
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
16
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
17 __END__
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
18
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
19 =pod
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
20
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
21 =head1 DESCRIPTION
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
22
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
23 Определяет порядок выполнения запроса, форматирует результат, инициализирует контекст.
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
24
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
25 Объект создается обработчиком запросов, таким как C<IMPL::Web::Application::UriController>.
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
26 При этом формируется цепочка обработчиков запроса, эта цапочка будет выполняться с последнего добавленного,
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
27 причем каждый добавленный обработчик в качестве одного из параметров получает не только текущий запрос,
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
28 но и предыдущий обработчик.
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
29
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
30 Типичная цепочка может быть такой, в порядке добавления
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
31
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
32 $objSecCallToMethod($target,$method)
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
33 $AuthenticateMethod
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
34 $TDocumentOut($file)
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
35
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
36 что приведет к следующей последовательности
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
37
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
38 Action->Invoke() {
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
39 TDocumentOut->Invoke($Action,$nextHandler) {
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
40 my $result = $nextHandler() {
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
41 $AuthenticateMethod($Action,$nextHandler) {
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
42 my $context = $Action->application->security->Authenticate($Action->request,$Action->response);
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
43 return $context->Impersonate($nextHandler) {
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
44 $objSecCallToMethod->Invoke($Action,undef) {
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
45 IMPL::Security->AccessCheck($target,$method);
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
46 return $target->$method();
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
47 }
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
48 }
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
49 }
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
50 }
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
51 $this->format($result,$Action->response->streamBody);
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
52 }
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
53 }
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
54
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
55 или как альтернатива может быть еще
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
56
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
57 $objSecCallToMethod($target,$method)
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
58 $AuthenticateMethod
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
59 $TransfromToSimpleData
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
60 $JSONOut
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
61
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
62 В данной цепочке также происходит вызов метода, но его результат потом преобразуется
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
63 в простые структуры и передается JSON преобразователю. Таким образом модулю логики
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
64 не требуется знать о выходном формате, всю работу проделают дополнительные фильтры.
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
65
15d720913562 security in work
wizard@linux-odin.local
parents:
diff changeset
66 =cut