changeset 311:d3b5a67ad2e8

sync
author cin
date Mon, 22 Apr 2013 03:42:53 +0400
parents 0a9d51cf6dfd
children 75a78cbf7dcf
files Lib/IMPL/Web/View/TTDocument.pm Lib/IMPL/Web/View/TTLoader.pm _test/dump.out
diffstat 3 files changed, 95 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/Lib/IMPL/Web/View/TTDocument.pm	Fri Apr 19 16:39:01 2013 +0400
+++ b/Lib/IMPL/Web/View/TTDocument.pm	Mon Apr 22 03:42:53 2013 +0400
@@ -24,18 +24,22 @@
     ],
     props => [
         layout => PROP_RW,
+        layoutBase => PROP_RW,
+        registry => PROP_RW,
         baseLocation => PROP_RW
     ]
 };
 
 sub CTOR {
-    my ($this,$template,$ctx,$vars) = @_;
+    my ($this,$template,$ctx) = @_;
     
     $this->layout( $template->layout ) unless $this->layout;
     $this->title( $template->title ) unless $this->title;
-    
-    $this->context->stash->update($vars)
-        if ref $vars eq 'HASH';
+    my $doc = $this;
+    weaken($doc);
+    $this->registry->context->stash->update({
+        document => sub { $doc }
+    });
 }
 
 sub Render {
@@ -44,9 +48,9 @@
     $args ||= {};
     $args->{document} = $this;
     
-    $this->context->stash->update({
-    	document => sub { $this }
-    });
+    #$this->context->stash->update({
+    #	document => sub { $this }
+    #});
     
     my $text = eval {
     
@@ -66,7 +70,7 @@
     
     my $e = $@;
     
-    undef $this;
+    # undef $this;
     
     if ($e) {
         die $e;
--- a/Lib/IMPL/Web/View/TTLoader.pm	Fri Apr 19 16:39:01 2013 +0400
+++ b/Lib/IMPL/Web/View/TTLoader.pm	Mon Apr 22 03:42:53 2013 +0400
@@ -85,6 +85,8 @@
     my $ctx = _clone_context($this->context);
     $this->context->delocalise();
     
+    $ctx->stash->update($vars);
+    
     my $registry = TTRegistry->new($this, $ctx);
     
     my $factory = TTFactory->new($tt->class || TTDocument, $tt, $ctx, $name, $registry);
@@ -92,7 +94,7 @@
     $vars->{registry} = $registry;
     $vars->{layoutBase} = $this->layoutBase;
     
-    return $factory->new( $vars );    
+    return $factory->new( $vars );
 }
 
 
--- a/_test/dump.out	Fri Apr 19 16:39:01 2013 +0400
+++ b/_test/dump.out	Mon Apr 22 03:42:53 2013 +0400
@@ -6,6 +6,7 @@
                    'date' => {
                                'now' => sub { "DUMMY" }
                              },
+                   'document' => sub { "DUMMY" },
                    'dynamic' => sub { "DUMMY" },
                    'dec' => sub { "DUMMY" },
                    '_STRICT' => undef,
@@ -115,9 +116,9 @@
                                                                                      }, 'Template::Document' ),
                                                                               1343890751,
                                                                               undef,
-                                                                              1366316725
+                                                                              1366549254
                                                                             ],
-                                                                            1366316725
+                                                                            1366549254
                                                                           ],
                                                                 'DELIMITER' => ':',
                                                                 'UNICODE' => 1,
@@ -6321,5 +6322,81 @@
                                                                  'IMPL_Web_View_TTLoader_isInitialized' => 1
                                                                }, 'IMPL::Web::View::TTLoader' ),
                    'IMPL_Web_View_TTRegistry__cache' => {}
-                 }, 'IMPL::Web::View::TTRegistry' )
+                 }, 'IMPL::Web::View::TTRegistry' ),
+          bless( {
+                   'IMPL_Web_View_TTFactory_initialized' => 1,
+                   'IMPL_Web_View_TTFactory_registry' => $VAR1->[2],
+                   'IMPL_Web_View_TTFactory_instances' => 1,
+                   'IMPL_Object_Factory_factory' => 'IMPL::Web::View::TTDocument',
+                   'IMPL_Web_View_TTFactory_baseLocation' => '',
+                   'IMPL_Web_View_TTFactory_context' => $VAR1->[1],
+                   'IMPL_Web_View_TTFactory_blocks' => $VAR1->[1]{'CONFIG'}{'LOAD_TEMPLATES'}[0]{'HEAD'}[2]{'_DEFBLOCKS'},
+                   'IMPL_Web_View_TTFactory_template' => $VAR1->[1]{'CONFIG'}{'LOAD_TEMPLATES'}[0]{'HEAD'}[2]
+                 }, 'IMPL::Web::View::TTFactory' ),
+          bless( {
+                   'require' => $VAR1->[0]{'require'},
+                   'global' => $VAR1->[0]{'global'},
+                   'date' => $VAR1->[0]{'date'},
+                   'inc' => $VAR1->[0]{'inc'},
+                   'dynamic' => $VAR1->[0]{'dynamic'},
+                   'dec' => $VAR1->[0]{'dec'},
+                   '_STRICT' => undef,
+                   'site' => $VAR1->[0]{'site'},
+                   'component' => '',
+                   'dojo' => $VAR1->[0]{'dojo'},
+                   'view' => $VAR1->[0]{'view'},
+                   'user' => 'test_user',
+                   '_DEBUG' => 0,
+                   '_PARENT' => $VAR1->[0]
+                 }, 'Template::Stash::XS' ),
+          bless( {
+                   'PREFIX_MAP' => $VAR1->[1]{'PREFIX_MAP'},
+                   'BLOCKS' => {
+                                 'CTOR' => $VAR1->[1]{'BLOCKS'}{'CTOR'}
+                               },
+                   'TRIM' => 0,
+                   'CONFIG' => {
+                                 'PREFIX_MAP' => $VAR1->[1]{'PREFIX_MAP'},
+                                 'BLOCKS' => $VAR1->[1]{'BLOCKS'},
+                                 'TRIM' => 0,
+                                 'LOAD_PLUGINS' => $VAR1->[1]{'CONFIG'}{'LOAD_PLUGINS'},
+                                 'LOAD_TEMPLATES' => $VAR1->[1]{'CONFIG'}{'LOAD_TEMPLATES'},
+                                 'BLKSTACK' => $VAR1->[1]{'BLKSTACK'},
+                                 'STASH' => $VAR1->[4],
+                                 '_ERROR' => '',
+                                 'DEBUG_FORMAT' => undef,
+                                 'DEBUG' => 0,
+                                 'EVAL_PERL' => 0,
+                                 'EXPOSE_BLOCKS' => 0,
+                                 'DEBUG_DIRS' => 0,
+                                 'RECURSION' => 0,
+                                 'INIT_BLOCKS' => $VAR1->[1]{'BLOCKS'},
+                                 'LOAD_FILTERS' => $VAR1->[1]{'CONFIG'}{'LOAD_FILTERS'}
+                               },
+                   'LOAD_PLUGINS' => $VAR1->[1]{'CONFIG'}{'LOAD_PLUGINS'},
+                   'LOAD_TEMPLATES' => $VAR1->[1]{'CONFIG'}{'LOAD_TEMPLATES'},
+                   'BLKSTACK' => [],
+                   'STASH' => $VAR1->[4],
+                   'DEBUG_FORMAT' => undef,
+                   '_ERROR' => '',
+                   'DEBUG' => 0,
+                   'EVAL_PERL' => 0,
+                   'EXPOSE_BLOCKS' => 0,
+                   'DEBUG_DIRS' => 0,
+                   'RECURSION' => 0,
+                   'INIT_BLOCKS' => $VAR1->[5]{'BLOCKS'},
+                   'LOAD_FILTERS' => $VAR1->[1]{'CONFIG'}{'LOAD_FILTERS'}
+                 }, 'Template::Context' ),
+          bless( {
+                   'IMPL_Web_View_TTControl_id' => '_16',
+                   'IMPL_Web_View_TTDocument_registry' => $VAR1->[2],
+                   'IMPL_Web_View_TTControl_template' => $VAR1->[1]{'CONFIG'}{'LOAD_TEMPLATES'}[0]{'HEAD'}[2],
+                   'IMPL_Web_View_TTControl_context' => $VAR1->[5],
+                   'IMPL_Web_View_TTDocument_layout' => undef,
+                   'IMPL_Web_View_TTControl_attributes' => {
+                                                             'factory' => $VAR1->[3],
+                                                             'title' => "\x{414}\x{43e}\x{43a}\x{443}\x{43c}\x{435}\x{43d}\x{442} 1"
+                                                           },
+                   'IMPL_Web_View_TTDocument_layoutBase' => 'Layout'
+                 }, 'IMPL::Web::View::TTDocument' )
         ];