[Zope-Checkins] CVS: Packages/App - special_dtml.py:1.20

Andreas Jung andreasjung@cvs.zope.org
Mon, 6 Aug 2001 11:38:17 -0400


Update of /cvs-repository/Packages/App
In directory cvs.zope.org:/tmp/cvs-serv29498

Modified Files:
	special_dtml.py 
Log Message:
Enhanced error reporting when a DTML file is not found.
Former versions reported just an AttributeError/_v_blocks.
Additionally the name of the missing file is logged.
This should make debugging somewhat easier.


=== Packages/App/special_dtml.py 1.19 => 1.20 ===
 ##############################################################################
 
-import DocumentTemplate, Common, Persistence, MethodObject, Globals, os
+import DocumentTemplate, Common, Persistence, MethodObject, Globals, os, sys
+from types import InstanceType
+from zLOG import LOG,WARNING
 
 class HTML(DocumentTemplate.HTML,Persistence.Persistent,):
     "Persistent HTML Document Templates"
@@ -164,6 +166,7 @@
     _Bindings_client = 'container'
 
     def __init__(self, name, _prefix=None, **kw):
+
         self.ZBindings_edit(defaultBindings)
         self._setFuncSignature()
         apply(DTMLFile.inheritedAttribute('__init__'),
@@ -240,6 +243,13 @@
             if value is _marker:
                 try: result = render_blocks(self._v_blocks, ns)
                 except DTReturn, v: result = v.v
+                except AttributeError: 
+                    if type(sys.exc_value)==InstanceType and sys.exc_value.args[0]=="_v_blocks":
+                        LOG("ZPublisher",WARNING,"DTML file '%s' not found" % self.raw) 
+                        raise "DTML file error","Check logfile for details"
+                    else:
+                        raise
+
                 self.ZDocumentTemplate_afterRender(ns, result)
                 return result
             else: