[Zope] sendmail in standard_error_message

Arian de Wit a.dewit@niwa.cri.nz
Mon, 3 Dec 2001 14:22:12 +1300


Hi All,

When I add a dtml-sendmail block to my standard_error_message, I no 
longer get the custom error page at all, but the built-in one (headed 
up "Site Error." I read in the archives that this can be due to the 
standard_error_message object itself raising an error, but I have put 
the code in another object and it works fine there.

Any idea what I've done wrong? Any help would be greatly appreciated. 
The code in question is included below.


Thanks a lot,

Arian


Here's the code for the standard_error_message object I'm using, 
which tests for a NotFound error to treat 404 errors differently. If 
the sendmail block is removed, it works fine. The mailhost object 
*does* exist -- the sendmail block works perfectly when used 
elsewhere.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
"http://www.w3.org/TR/html40/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>
<dtml-if "error_type=='NotFound'">
Page Not Found - NIWA
<dtml-else>
Website Error - NIWA
</dtml-if>
</title>
<dtml-var style>
</head>
<body class="paddedminimal">

<img id="mainlogo" src="/niwalogo300.jpg" alt="NIWA" width="300" 
height="51">

<dtml-if "error_type=='NotFound'">

<h1>Page Not Found</h1>

<p>Sorry &#8211; the page requested couldn&#8217;t be found.</p>

<dtml-sendmail mailhost="mailhost">
To: a.dewit@niwa.co.nz
From: web@niwa.co.nz
Subject: 404 Error

URL: <dtml-var SERVER_URL><dtml-var PATH_INFO><dtml-if 
QUERY_STRING>?<dtml-var QUERY_STRING></dtml-if>

Referrer: <dtml-var HTTP_REFERER>

</dtml-sendmail>

URL: <dtml-var SERVER_URL><dtml-var PATH_INFO><dtml-if 
QUERY_STRING>?<dtml-var QUERY_STRING></dtml-if>

Referrer: <dtml-var HTTP_REFERER>

<dtml-else>

  <h1>Website Error</h1>

  <p>Zope has encountered an error while publishing this 
resource.</p>
  
  <p>
  <strong>Error Type: <dtml-var error_type></strong><br>
  <strong>Error Value: <dtml-var error_value></strong><br> 
  </p>
 
  <hr>
 
  <p>Troubleshooting Suggestions</p>

  <ul>
  <li>The URL may be incorrect. Try using the links above or the 
Search box below to find what you're looking for.</li>
  <dtml-if "error_type in ('KeyError','NameError')">
  <li>This resource may be trying to reference a
  nonexistent object or variable <strong><dtml-var 
error_value></strong>.</li>
  </dtml-if>
  <li>The parameters passed to this resource may be incorrect.</li>
  <li>A resource that this resource relies on may be encountering an 
error.</li>
  </ul>

  <p>If the error persists please contact us [<a 
href="mailto:webteam@niwa.co.nz">webteam@niwa.co.nz</a>].
  Thank you for your patience.
  </p>

<dtml-comment>
 Here, events like logging and other actions may also be performed, 
such as
 sending mail automatically to the administrator.
</dtml-comment>

 </dtml-if>

</body>
</html>
 
 ------------------------------------------------------------------
Arian de Wit
Information Systems Integration Manager
NIWA (National Institute of Water & Atmospheric Research)
Gate 10 Silverdale Road, Box 11-115, Hamilton, New Zealand 2001
Phone (+64) 7-856 1769
Fax (+64) 7-856 0151
Web http://www.niwa.co.nz
 ------------------------------------------------------------------