[ZPT] Compilation errors

Fred L. Drake, Jr. fdrake@acm.org
Mon, 12 Nov 2001 11:18:54 -0500


Richard Jones writes:
 > If a template fails compilation and an attempt is made to render
 > it, the exception raised is a RuntimeError. I think this should be
 > changed to something that is a little more unique to ZPT, so I can
 > catch the exception an not worry about catching stray RuntimeErrors
 > raised by faults in e.g. the Python interpreter (I don't beileve
 > anything else raises RuntimeErrors.)  Sure, use RuntimeError as a
 > base class, but maybe PTRuntimeError at a minimum?
 > 
 > Yes/No/Indifferent?

  Yes, maybe.
  I just grepped the sources for TAL, ZTUtils, and
Products/PageTemplate, and the only RuntimeError grep found was this
one.  I don't understand enough of why the error state is managed the
way it is in PageTemplates, but I'd expect the error to be raised by
PageTemplate._cook(); the pt_render() method should simply attempt to
compile the template if a cooked version isn't already available.
  Evan, can you elaborate on why compilation errors are handled this
way?  I'm sure I just don't understand enough about the way requests
are handled within Zope.


  -Fred

-- 
Fred L. Drake, Jr.  <fdrake at acm.org>
PythonLabs at Zope Corporation