[Zope-Checkins] SVN: Zope/branches/ajung-zpt-end-game/lib/python/Products/PageTemplates/PageTemplate.py We also need a new read() method due to the call signature incompabilities.

Philipp von Weitershausen philikon at philikon.de
Mon May 22 15:52:01 EDT 2006


Log message for revision 68245:
  We also need a new read() method due to the call signature incompabilities.
  

Changed:
  U   Zope/branches/ajung-zpt-end-game/lib/python/Products/PageTemplates/PageTemplate.py

-=-
Modified: Zope/branches/ajung-zpt-end-game/lib/python/Products/PageTemplates/PageTemplate.py
===================================================================
--- Zope/branches/ajung-zpt-end-game/lib/python/Products/PageTemplates/PageTemplate.py	2006-05-22 18:52:50 UTC (rev 68244)
+++ Zope/branches/ajung-zpt-end-game/lib/python/Products/PageTemplates/PageTemplate.py	2006-05-22 19:52:00 UTC (rev 68245)
@@ -17,7 +17,7 @@
 import sys
 import ExtensionClass
 import zope.pagetemplate.pagetemplate
-from zope.pagetemplate.pagetemplate import PTRuntimeError
+from zope.pagetemplate.pagetemplate import _error_start, PTRuntimeError
 from zope.pagetemplate.pagetemplate import PageTemplateTracebackSupplement
 from zope.tales.expressions import SimpleModuleImporter
 from Products.PageTemplates.Expressions import getEngine
@@ -103,6 +103,22 @@
             kwargs['args'] = args
         return self.pt_render(extra_context={'options': kwargs})
 
+    def read(self):
+        self._cook_check()
+        if not self._v_errors:
+            if not self.expand:
+                return self._text
+            try:
+                return self.pt_render(source=True)
+            except:
+                return ('%s\n Macro expansion failed\n %s\n-->\n%s' %
+                        (_error_start, "%s: %s" % sys.exc_info()[:2],
+                         self._text) )
+
+        return ('%s\n %s\n-->\n%s' % (_error_start,
+                                      '\n '.join(self._v_errors),
+                                      self._text))
+
     # convenience method for the ZMI which allows to explicitly
     # specify the HTMLness of a template.  The old Zope 2
     # implementation had this as well, but arguably on the wrong class



More information about the Zope-Checkins mailing list