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

Fred L. Drake, Jr. fdrake@acm.org
Thu, 21 Mar 2002 17:12:40 -0500


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

Modified Files:
      Tag: Zope-3x-branch
	PageTemplate.py 
Log Message:
Fix "Nasty bug" reported by Guido; pt_render() now gets the right number of
parameters in all cases.  One case does not get a useful value, but it may
not be needed (marked with XXX comment).
I would love to be able to write a test case that demonstrates the bug in the
original code and that this fixes it, but I have not figured that out yet.


=== Zope3/lib/python/Zope/PageTemplate/PageTemplate.py 1.1.2.14 => 1.1.2.15 ===
         """Render this Page Template"""
         self._cook_check()
-        __traceback_supplement__ = (PageTemplateTracebackSupplement, self)
+        __traceback_supplement__ = (PageTemplateTracebackSupplement,
+                                    self, namespace)
         if self._v_errors:
             raise PTRuntimeError(str(self._v_errors))
         output = StringIO()
@@ -100,13 +101,13 @@
     def __call__(self, *args, **kwargs):
         return self.pt_render(self.pt_getContext(*args, **kwargs))
 
-    def pt_errors(self):
+    def pt_errors(self, namespace):
         self._cook_check()
         err = self._v_errors
         if err:
             return err
         try:
-            self.pt_render(source=1)
+            self.pt_render(namespace, source=1)
         except:
             return ('Macro expansion failed', '%s: %s' % sys.exc_info()[:2])
 
@@ -131,7 +132,9 @@
             if not self.expand:
                 return self._text
             try:
-                return self.pt_render(source=1)
+                # XXX not clear how this ever gets called, but the
+                # first arg to pt_render() needs to change if it ever does.
+                return self.pt_render({}, source=1)
             except:
                 return ('%s\n Macro expansion failed\n %s\n-->\n%s' %
                         (self._error_start, "%s: %s" % sys.exc_info()[:2],
@@ -189,13 +192,13 @@
 class PageTemplateTracebackSupplement:
     #__implements__ = ITracebackSupplement
 
-    def __init__(self, pt):
+    def __init__(self, pt, namespace):
         self.manageable_object = pt
         try:
             w = pt.pt_warnings()
         except: # We're already trying to report an error, don't make another.
             w = ()
-        e = pt.pt_errors()
+        e = pt.pt_errors(namespace)
         if e:
             w = list(w) + list(e)
         self.warnings = w