[Checkins] SVN: grok/branches/regebro-guido-templates/ Added the view override/extension fo the namespace.

Lennart Regebro regebro at gmail.com
Sat Oct 20 11:34:17 EDT 2007


Log message for revision 80949:
  Added the view override/extension fo the namespace.
  

Changed:
  U   grok/branches/regebro-guido-templates/doc/minitutorials/template-languages.txt
  U   grok/branches/regebro-guido-templates/src/grok/components.py

-=-
Modified: grok/branches/regebro-guido-templates/doc/minitutorials/template-languages.txt
===================================================================
--- grok/branches/regebro-guido-templates/doc/minitutorials/template-languages.txt	2007-10-20 15:33:22 UTC (rev 80948)
+++ grok/branches/regebro-guido-templates/doc/minitutorials/template-languages.txt	2007-10-20 15:34:17 UTC (rev 80949)
@@ -41,7 +41,9 @@
             return namespace
     
         def render(self, view):
-            return self._template.render(**self.namespace(view))
+            namespace = self.namespace(view)
+            namespace.update(view.namespace())        
+            return self._template.render(**namespace)
 
 In the __init__ method of a typical template you pass in what should be
 rendered. This is usually HTML, but can equally well be XML or text, or

Modified: grok/branches/regebro-guido-templates/src/grok/components.py
===================================================================
--- grok/branches/regebro-guido-templates/src/grok/components.py	2007-10-20 15:33:22 UTC (rev 80948)
+++ grok/branches/regebro-guido-templates/src/grok/components.py	2007-10-20 15:34:17 UTC (rev 80949)
@@ -125,7 +125,7 @@
         return self.template.render(self)
 
     def namespace(self):
-        return self.template.namespace()        
+        return {}
 
     def __getitem__(self, key):
         if getattr(self.template, 'macros', None) is None:
@@ -242,7 +242,9 @@
         return namespace
 
     def render(self, view):
-        return self.pt_render(self.namespace(view))
+        namespace = self.namespace(view)
+        namespace.update(view.namespace())
+        return self.pt_render(namespace)
 
 
 class PageTemplateFile(GrokPageTemplate, TrustedAppPT,



More information about the Checkins mailing list