annotate Lib/IMPL/Web/View/TTRegistry.pm @ 330:fe725fad2d90

Added access checking to web resources
author sergey
date Tue, 04 Jun 2013 19:25:54 +0400
parents 5e4e7c8fbca1
children 72799d1211c5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
304
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
1 package IMPL::Web::View::TTRegistry;
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
2 use strict;
305
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
3 use mro;
304
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
4
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
5 use IMPL::Const qw(:prop);
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
6 use IMPL::declare {
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
7 require => {
309
cin
parents: 305
diff changeset
8 TTFactory => 'IMPL::Web::View::TTFactory',
cin
parents: 305
diff changeset
9 TTControl => '-IMPL::Web::View::TTControl'
304
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
10 },
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
11 base => [
305
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
12 'IMPL::Object' => undef,
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
13 'IMPL::Object::Disposable' => undef
304
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
14 ],
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
15 props => [
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
16 loader => PROP_RW,
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
17 context => PROP_RW,
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
18 _cache => PROP_RW,
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
19 ]
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
20 };
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
21
305
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
22 sub CTOR {
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
23 my ($this,$loader,$context) = @_;
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
24
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
25 $this->loader($loader);
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
26 $this->context($context);
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
27 $this->_cache({});
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
28 }
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
29
304
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
30 sub Require {
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
31 my ($this,$name) = @_;
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
32
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
33 if(my $factory = $this->_cache->{$name}) {
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
34 return $factory;
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
35 } else {
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
36 my $template = $this->loader->template($name)
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
37 or die AppException->new("Failed to load a template $name");
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
38
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
39 $factory = TTFactory->new(
309
cin
parents: 305
diff changeset
40 $template->class || TTControl,
304
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
41 $template,
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
42 $this->context,
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
43 $name,
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
44 $this
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
45 );
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
46
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
47 $this->_cache->{$name} = $factory;
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
48 return $factory;
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
49 }
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
50 }
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
51
305
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
52 sub Dispose {
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
53 my ($this) = @_;
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
54
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
55 $this->_cache(undef);
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
56 $this->context(undef);
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
57 $this->loader(undef);
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
58
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
59 $this->next::method();
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
60 }
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
61
304
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
62 1;
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
63
2ff513227cb4 *TTView: refactoring. Added control registry for the document.
cin
parents:
diff changeset
64 __END__
305
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
65
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
66 =pod
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
67
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
68 =head1 NAME
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
69
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
70 C<IMPL::Web::View::Registry> - реестр шаблонов документа.
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
71
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
72 =head1 DESCRIPTION
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
73
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
74 Используется для реализации функции C<require> внутри шаблонов.
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
75
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
76
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
77
b5d5793f348e TTView refactoring, still experiencing memory leaks
sergey
parents: 304
diff changeset
78 =cut