[Zope-Checkins] CVS: Zope3/lib/python/Zope/PageTemplate - PageTemplateFile.py:1.1.2.12

Fred L. Drake, Jr. fdrake@acm.org
Fri, 1 Feb 2002 17:12:07 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/PageTemplate
In directory cvs.zope.org:/tmp/cvs-serv3922

Modified Files:
      Tag: Zope-3x-branch
	PageTemplateFile.py 
Log Message:
Simplify PageTemplateFile to take advantage of the new Zope-specific
base classes.


=== Zope3/lib/python/Zope/PageTemplate/PageTemplateFile.py 1.1.2.11 => 1.1.2.12 ===
 __metatype__ = type
 
-__version__='$Revision$'[11:-2]
+__version__ = '$Revision$'[11:-2]
 
 import os, sys
 from zLOG import LOG, ERROR, INFO
-from string import join, strip, rstrip, split, lower
-from PageTemplate import PageTemplate, ViewMapper
+from string import join
+from ViewZPT import ViewZPT
 from Expressions import SecureModuleImporter
 from Zope.Misc.package_home import package_home
 
@@ -31,7 +31,7 @@
         return parent._v_macros
 
 
-class PageTemplateFile(PageTemplate):
+class PageTemplateFile(ViewZPT):
     "Zope wrapper for filesystem Page Template using TAL, TALES, and METAL"
 
     meta_type = 'Page Template (File)'
@@ -50,35 +50,15 @@
             filename = filename + '.zpt'
         self.filename = os.path.join(_prefix, filename)
 
-    def pt_getContext(self, inst=None, request=None):
-        #root = self.getPhysicalRoot()
-        c = {'template': self,
-             'nothing': None,
-             #XXX 'root': root,
-             'modules': SecureModuleImporter,
-             }
-        if inst is not None:
-            c['here'] = inst.getContext()
-            c['container'] = inst
-            c['views'] = ViewMapper(inst.getContext(), request)
-        return c
+    def pt_getContext(self, **keywords):
+        namespace = ViewZPT.pt_getContext(self, **keywords)
+        namespace['modules'] = SecureModuleImporter
+        return namespace
 
-    def __call__(self, inst, REQUEST=None, **kw):
+    def __call__(self, *args, **kw):
         """Call a Page Template"""
         self._cook_check()
-        bound_names = {}
-        bound_names.update(self.pt_getContext(inst, REQUEST))
-        bound_names['options'] = kw
-        bound_names['request'] = REQUEST
-
-        try:
-            self.REQUEST.RESPONSE.setHeader('content-type',
-                                            self.content_type)
-        except AttributeError:
-            pass
-
-        # Execute the template in a new security context.
-        return self.pt_render(extra_context=bound_names)
+        return ViewZPT.__call__(self, *args, **kw)
 
     def _cook_check(self):
         if self._v_last_read and not DevelopmentMode: