[Checkins] SVN: grok/branches/regebro-guido-templates/src/grok/components.py The view is not template agnostic.

Lennart Regebro regebro at gmail.com
Tue Oct 2 11:29:57 EDT 2007


Log message for revision 80503:
  The view is not template agnostic.
  

Changed:
  U   grok/branches/regebro-guido-templates/src/grok/components.py

-=-
Modified: grok/branches/regebro-guido-templates/src/grok/components.py
===================================================================
--- grok/branches/regebro-guido-templates/src/grok/components.py	2007-10-02 15:24:38 UTC (rev 80502)
+++ grok/branches/regebro-guido-templates/src/grok/components.py	2007-10-02 15:29:57 UTC (rev 80503)
@@ -123,13 +123,7 @@
         return mapply(self.render, (), self.request)
 
     def _render_template(self):
-        namespace = self.template.pt_getContext()
-        namespace['request'] = self.request
-        namespace['view'] = self
-        namespace['context'] = self.context
-        # XXX need to check whether we really want to put None here if missing
-        namespace['static'] = self.static
-        return self.template.pt_render(namespace)
+        return self.template._render_template(self)
 
     def __getitem__(self, key):
         if getattr(self.template, 'macros', None) is None:
@@ -226,6 +220,16 @@
 
     def _factory_init(self, factory):
         factory.macros = self.macros
+        
+    def _render_template(self, view):
+        namespace = self.pt_getContext()
+        namespace['request'] = view.request
+        namespace['view'] = view
+        namespace['context'] = view.context
+        # XXX need to check whether we really want to put None here if missing
+        namespace['static'] = view.static
+        return self.pt_render(namespace)
+    
 
 class PageTemplateFile(GrokPageTemplate, TrustedAppPT,
                        pagetemplatefile.PageTemplateFile):
@@ -245,6 +249,15 @@
     def _factory_init(self, factory):
         factory.macros = self.macros
 
+    def _render_template(self, view):
+        namespace = self.pt_getContext()
+        namespace['request'] = view.request
+        namespace['view'] = view
+        namespace['context'] = view.context
+        # XXX need to check whether we really want to put None here if missing
+        namespace['static'] = view.static
+        return self.pt_render(namespace)
+
 class GenshiMarkupTemplate(GrokPageTemplate):
 
     interface.implements(interfaces.ITemplateFile)
@@ -268,12 +281,13 @@
     def _factory_init(self, factory):
         pass
     
-    # XXX Ugly temporary ZPT emulation
-    def pt_getContext(self):
-        return {}
-
-    # XXX Ugly temporary ZPT emulation
-    def pt_render(self, namespace):
+    def _render_template(self, view):
+        namespace = {}
+        namespace['request'] = view.request
+        namespace['view'] = view
+        namespace['context'] = view.context
+        # XXX need to check whether we really want to put None here if missing
+        namespace['static'] = view.static
         return self(namespace)
 
     



More information about the Checkins mailing list