[ZPT] Compilation errors

Evan Simpson evan@zope.com
Mon, 12 Nov 2001 11:48:19 -0500


Fred L. Drake, Jr. wrote:

> Richard Jones writes:
>  > base class, but maybe PTRuntimeError at a minimum?
>  > 
>  > Yes/No/Indifferent?


Yes, this makes sense.

>   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.

   Page Templates exemplify a new way of handling "language object" errors. 
  Objects such as DTML Methods, Scripts, and Page Templates all accept 
source code of one sort or another.  Unlike File or Document objects, for 
instance, these objects can contain text that is invalid, in the sense that 
it is syntactically malformed or otherwise doesn't compile.

   The old way of handling attempts to save invalid text is to raise an 
exception.  This is a somewhat annoying but reasonable response when you're 
using the ZMI edit page for the object, but fails badly when using WebDAV, 
or FTP, or a bulk site loader, or Copy to Present on the History tab.  In 
all of these cases, there is either no way to see the error message or no 
way to correct the text being loaded.  This results in frustration since the 
user is merely told "Save failed.", or equivalent.

   The new approach is to accept the invalid text and place the object in an 
error state, where attempts to use it raise an exception.  Visiting the 
object in the ZMI lets you see and correct the exact source problem.  When 
possible, reading the source by other means should also give you information 
about the problem (i.e. Page Templates' embedded error comment).

Cheers,

Evan @ Zope