[Checkins] SVN: z3c.pt/trunk/ The ViewPageTemplateFile class now uses 'path' as the default expression type.

Malthe Borch mborch at gmail.com
Mon Sep 1 05:25:10 EDT 2008


Log message for revision 90638:
  The ViewPageTemplateFile class now uses 'path' as the default expression type.

Changed:
  U   z3c.pt/trunk/CHANGES.txt
  U   z3c.pt/trunk/src/z3c/pt/pagetemplate.py
  U   z3c.pt/trunk/src/z3c/pt/tests/view.pt

-=-
Modified: z3c.pt/trunk/CHANGES.txt
===================================================================
--- z3c.pt/trunk/CHANGES.txt	2008-09-01 09:24:32 UTC (rev 90637)
+++ z3c.pt/trunk/CHANGES.txt	2008-09-01 09:25:09 UTC (rev 90638)
@@ -6,6 +6,9 @@
 
   Backwards incompatibilities
 
+- The ``ViewPageTemplateFile`` class now uses 'path' as the default
+  expression type. [malthe]
+  
 - The compiler now expects an instantiated parser instance. [malthe]
 
   Features

Modified: z3c.pt/trunk/src/z3c/pt/pagetemplate.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/pagetemplate.py	2008-09-01 09:24:32 UTC (rev 90637)
+++ z3c.pt/trunk/src/z3c/pt/pagetemplate.py	2008-09-01 09:25:09 UTC (rev 90638)
@@ -24,7 +24,7 @@
 class PageTemplate(template.BaseTemplate):
     __doc__ = template.BaseTemplate.__doc__ # for Sphinx autodoc
 
-    default_parser = zpt.ZopePageTemplateParser
+    default_parser = zpt.ZopePageTemplateParser()
     
     def __init__(self, body, parser=None, format=None, doctype=None):
         if parser is None:
@@ -38,7 +38,7 @@
 class PageTemplateFile(template.BaseTemplateFile):
     __doc__ = template.BaseTemplateFile.__doc__ # for Sphinx autodoc
 
-    default_parser = zpt.ZopePageTemplateParser
+    default_parser = zpt.ZopePageTemplateParser()
     
     def __init__(self, filename, parser=None, format=None,
                  doctype=None, **kwargs):
@@ -51,15 +51,22 @@
         super(PageTemplateFile, self).prepare(kwargs)
         prepare_language_support(kwargs)
 
+class ZopePageTemplate(PageTemplate):
+    default_parser = zpt.ZopePageTemplateParser(default_expression='path')
+
+class ZopePageTemplateFile(PageTemplateFile):
+    default_parser = zpt.ZopePageTemplateParser(default_expression='path')
+
 class ViewPageTemplate(property):
     """Template class suitable for use with a Zope browser view; the
     variables ``view``, ``context`` and ``request`` variables are
     brought in to the local scope of the template automatically, while
     keyword arguments are passed in through the ``options``
-    dictionary."""
+    dictionary. Note that the default expression type for this class
+    is 'path' (standard Zope traversal)."""
     
     def __init__(self, body, **kwargs):
-        self.template = PageTemplate(body, **kwargs)
+        self.template = ZopePageTemplate(body, **kwargs)
         property.__init__(self, self.render)
 
     def render(self, view):
@@ -91,8 +98,8 @@
                 path = path[:path.rfind(os.sep)]	 
  	 
             filename = path + os.sep + filename
-        
-        self.template = PageTemplateFile(filename, **kwargs)
+
+        self.template = ZopePageTemplateFile(filename, **kwargs)
         property.__init__(self, self.render)
 
     def __call__(self, view, **kwargs):

Modified: z3c.pt/trunk/src/z3c/pt/tests/view.pt
===================================================================
--- z3c.pt/trunk/src/z3c/pt/tests/view.pt	2008-09-01 09:24:32 UTC (rev 90637)
+++ z3c.pt/trunk/src/z3c/pt/tests/view.pt	2008-09-01 09:25:09 UTC (rev 90638)
@@ -1,7 +1,7 @@
 <div xmlns="http://www.w3.org/1999/xhtml"
      xmlns:tal="http://xml.zope.org/namespaces/tal">
-  <span tal:content="view" />
+  <span tal:content="nocall: view" />
   <span tal:content="context" />
   <span tal:content="request" />
-  <span tal:content="options.test" />
+  <span tal:content="options/test" />
 </div>



More information about the Checkins mailing list