[Checkins] SVN: zmi.core/trunk/src/zmi/core/error/ Copy browser code from zope.app.error.

Yusei Tahara yusei at domen.cx
Sun Jun 7 11:25:32 EDT 2009


Log message for revision 100692:
  Copy browser code from zope.app.error.
  

Changed:
  A   zmi.core/trunk/src/zmi/core/error/__init__.py
  A   zmi.core/trunk/src/zmi/core/error/configure.zcml
  A   zmi.core/trunk/src/zmi/core/error/error.gif
  A   zmi.core/trunk/src/zmi/core/error/error.pt
  A   zmi.core/trunk/src/zmi/core/error/error_config.pt
  A   zmi.core/trunk/src/zmi/core/error/error_service.gif
  A   zmi.core/trunk/src/zmi/core/error/errorentry.pt
  A   zmi.core/trunk/src/zmi/core/error/texttbentry.pt

-=-
Added: zmi.core/trunk/src/zmi/core/error/__init__.py
===================================================================
--- zmi.core/trunk/src/zmi/core/error/__init__.py	                        (rev 0)
+++ zmi.core/trunk/src/zmi/core/error/__init__.py	2009-06-07 15:25:32 UTC (rev 100692)
@@ -0,0 +1,53 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Define view component for event utility control.
+
+$Id: __init__.py 85561 2008-04-21 18:19:53Z lgs $
+"""
+from zope.component import getUtility
+from zope.publisher.browser import BrowserView
+from zope.traversing.browser.absoluteurl import absoluteURL
+
+from zope.error.interfaces import IErrorReportingUtility
+from zope.error.interfaces import ILocalErrorReportingUtility
+
+
+class EditErrorLog(object):
+    __used_for__ = ILocalErrorReportingUtility
+
+    def updateProperties(self, keep_entries, copy_to_zlog=None,
+                         ignored_exceptions=None):
+        errorLog = self.context
+        if copy_to_zlog is None:
+            copy_to_zlog = 0
+        errorLog.setProperties(keep_entries, copy_to_zlog, ignored_exceptions)
+        return self.request.response.redirect('@@configure.html')
+
+
+class ErrorRedirect(BrowserView):
+
+    def action(self):
+        # Some locations (eg ++etc++process) throw a TypeError exception when
+        # finding their absoluteurl, if this happens catch the error and
+        # redirect the browser to the site root "/@@errorRedirect.html"
+        # to handle redirection to the site error logger instead
+        try:
+            err = getUtility(IErrorReportingUtility)
+            url = absoluteURL(err, self.request)
+        except TypeError:
+            url = self.request.getApplicationURL() + "/@@errorRedirect.html"
+        else:
+            url = url + "/@@SelectedManagementView.html"
+
+        self.request.response.redirect(url)

Added: zmi.core/trunk/src/zmi/core/error/configure.zcml
===================================================================
--- zmi.core/trunk/src/zmi/core/error/configure.zcml	                        (rev 0)
+++ zmi.core/trunk/src/zmi/core/error/configure.zcml	2009-06-07 15:25:32 UTC (rev 100692)
@@ -0,0 +1,42 @@
+<zope:configure
+    xmlns:zope="http://namespaces.zope.org/zope"
+    xmlns="http://namespaces.zope.org/browser">
+
+  <page
+      for="*"
+      name="errorRedirect.html"
+      permission="zope.ManageServices"
+      class=".ErrorRedirect"
+      attribute="action"
+      menu="zmi_actions"
+      title="Errors"
+      />
+
+  <!--Error Logging Utility -->
+
+  <pages
+      for="zope.error.interfaces.IErrorReportingUtility"
+      permission="zope.ManageServices"
+      class=".EditErrorLog">
+
+    <page name="index.html" template="error.pt"
+          menu="zmi_views" title="Errors" />
+    <page name="configure.html" template="error_config.pt"
+          menu="zmi_views" title="Configure" />
+    <page name="edit.html" attribute="updateProperties" />
+    <page name="showEntry.html" template="errorentry.pt"/>
+    <page name="showTextTBEntry.html" template="texttbentry.pt"/>
+  </pages>
+
+  <addMenuItem
+     class="zope.error.error.ErrorReportingUtility"
+     title="Error Logging Utility"
+     description="Error Reporting Utility for Logging Errors"
+     permission="zope.ManageServices" />
+
+  <icon name="zmi_icon"
+      for="zope.error.interfaces.IErrorReportingUtility"
+      file="error.gif" />
+
+</zope:configure>
+

Added: zmi.core/trunk/src/zmi/core/error/error.gif
===================================================================
(Binary files differ)


Property changes on: zmi.core/trunk/src/zmi/core/error/error.gif
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: zmi.core/trunk/src/zmi/core/error/error.pt
===================================================================
--- zmi.core/trunk/src/zmi/core/error/error.pt	                        (rev 0)
+++ zmi.core/trunk/src/zmi/core/error/error.pt	2009-06-07 15:25:32 UTC (rev 100692)
@@ -0,0 +1,61 @@
+<html metal:use-macro="context/@@standard_macros/view"
+    i18n:domain="zope">
+<head>
+  <title metal:fill-slot="title" i18n:translate="">View Error Log Report</title>
+</head>
+<body>
+<div metal:fill-slot="body">
+
+    <h3 i18n:translate="">Exception Log (most recent first)</h3>
+
+    <p i18n:translate="">This page lists the exceptions that have occurred
+    in this site recently.</p>
+
+    <div tal:define="entries context/getLogEntries">
+
+      <em tal:condition="not:entries" i18n:translate="">
+        No exceptions logged.
+      </em>
+
+      <table tal:condition="entries">
+        <tr>
+          <th align="left" i18n:translate="">Time</th>
+          <th align="left" i18n:translate="">User</th>
+          <th align="left" i18n:translate="">Exception</th>
+        </tr>
+
+        <tr tal:repeat="entry entries">
+          <td valign="top" nowrap="nowrap">
+            <span tal:content="entry/time">Time</span>
+          </td>
+          <td>
+            <span tal:content="entry/username">joe</span>
+          </td>
+          <td valign="top">
+            <a href="showEntry" 
+               tal:attributes="href string:showEntry.html?id=${entry/id}">
+              <span tal:content="entry/type">AttributeError</span>:
+              <span tal:define="value entry/value"
+                    tal:content="python: 
+                       len(value) < 70 and value or value[:70] + '...'">
+                Application object has no attribute "zzope"
+              </span>
+            </a>
+          </td>
+        </tr>
+      </table>
+ 
+    </div>
+
+  <form action="index.html" method="get">
+    <div class="row">
+      <div class="controls">
+        <input type="submit" name="submit" value="Refresh" 
+            i18n:attributes="value refresh-button" />
+      </div>
+    </div>
+  </form>
+
+</div>
+</body>
+</html>

Added: zmi.core/trunk/src/zmi/core/error/error_config.pt
===================================================================
--- zmi.core/trunk/src/zmi/core/error/error_config.pt	                        (rev 0)
+++ zmi.core/trunk/src/zmi/core/error/error_config.pt	2009-06-07 15:25:32 UTC (rev 100692)
@@ -0,0 +1,56 @@
+<html metal:use-macro="context/@@standard_macros/view"
+    i18n:domain="zope">
+<head>
+  <title metal:fill-slot="title" i18n:translate="">Configure Error Log</title>
+</head>
+<body>
+<div metal:fill-slot="body">
+
+  <p class="form-help" i18n:translate="">
+    You can configure how many exceptions should be kept
+    and whether the exceptions should be copied to Zope's event log
+    file(s).
+  </p>
+
+  <form action="edit.html" method="post"
+        tal:define="props context/getProperties">
+    <br />
+    <div class="row">
+      <div class="label" i18n:translate="">Number of exceptions to keep</div>
+      <div class="field">
+        <input type="text" name="keep_entries" size="40"
+               tal:attributes="value props/keep_entries" />
+      </div>
+    </div>
+
+    <div class="row">
+      <div class="label" i18n:translate="">
+        Copy exceptions to the event log
+      </div>
+      <div class="field">
+        <input type="checkbox" name="copy_to_zlog"
+               tal:attributes="checked props/copy_to_zlog" />
+      </div>
+    </div>
+
+    <div class="row">
+      <div class="label" i18n:translate="">Ignored exception types</div>
+      <div class="field">
+        <textarea name="ignored_exceptions:lines" cols="40" rows="3"
+            tal:content="python: '\n'.join(props['ignored_exceptions'])" />
+      </div>
+    </div>
+    <div class="separator"></div>
+
+    <div class="row">
+      <div class="controls">
+        <input type="submit" name="submit" value="Save Changes"
+                i18n:attributes="value save-changes-button"/>
+      </div>
+    </div>
+  
+  </form>
+
+</div>
+</body>
+</html>

Added: zmi.core/trunk/src/zmi/core/error/error_service.gif
===================================================================
(Binary files differ)


Property changes on: zmi.core/trunk/src/zmi/core/error/error_service.gif
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: zmi.core/trunk/src/zmi/core/error/errorentry.pt
===================================================================
--- zmi.core/trunk/src/zmi/core/error/errorentry.pt	                        (rev 0)
+++ zmi.core/trunk/src/zmi/core/error/errorentry.pt	2009-06-07 15:25:32 UTC (rev 100692)
@@ -0,0 +1,87 @@
+<html metal:use-macro="context/@@standard_macros/page"
+    i18n:domain="zope">
+<head>
+  <title metal:fill-slot="title" i18n:translate="">View Error Log Report</title>
+</head>
+<body>
+<div metal:fill-slot="body"
+     tal:define="entry python:context.getLogEntryById(request.get('id'))">
+
+  <h1 i18n:translate="">Header</h1>
+
+  <h3 i18n:translate="">Exception traceback</h3>
+
+  <em tal:condition="not:entry" i18n:translate="">
+    The specified log entry was not found.  It may have expired.
+  </em>
+
+  <div tal:condition="entry">
+
+    <div class="row">
+      <div class="label" i18n:translate="">Time</div>
+      <div class="field" tal:content="entry/time">Time</div>
+    </div>
+
+    <div class="row">
+      <div class="label" i18n:translate="">User</div>
+      <div class="field" tal:content="entry/username">joe</div>
+    </div>
+
+    <div class="row">
+      <div class="label" i18n:translate="">Request URL</div>
+      <div class="field" tal:content="entry/url">http://zeomega.com</div>
+    </div>
+
+    <div class="row">
+      <div class="label" i18n:translate="">Exception Type</div>
+      <div class="field" tal:content="entry/type">AttributeError</div>
+    </div>
+
+    <div class="row">
+      <div class="label" i18n:translate="">Exception Value</div>
+      <div class="field" tal:content="entry/value">zzope</div>
+    </div>
+
+    <div class="row">
+      <div class="label" i18n:translate="">Traceback</div>
+      <div class="field">&nbsp;</div>
+    </div>
+    <br/>
+
+    <div tal:condition="entry/tb_html" tal:content="structure entry/tb_html">
+      Traceback (HTML)
+    </div>
+
+    <pre tal:condition="not:entry/tb_html" tal:content="entry/tb_text">
+      Traceback (text)
+    </pre>
+
+    <p tal:condition="entry/tb_text">
+      <a href="" 
+         tal:attributes="href string:showTextTBEntry.html?id=${entry/id}" 
+         i18n:translate="">Display traceback as text</a>
+    </p>
+
+
+    <div tal:condition="entry/req_html">
+
+      <h3 i18n:translate="">REQUEST</h3>
+
+      <div tal:replace="structure entry/req_html"></div>
+
+    </div>
+
+  </div>
+
+  <form action="index.html" method="get">
+    <div class="row">
+      <div class="controls">
+        <input type="submit" name="submit" value="Return to log" 
+                i18n:attributes="value return-to-log-button" />
+        </div>
+    </div>
+  </form>
+
+</div>
+</body>
+</html>

Added: zmi.core/trunk/src/zmi/core/error/texttbentry.pt
===================================================================
--- zmi.core/trunk/src/zmi/core/error/texttbentry.pt	                        (rev 0)
+++ zmi.core/trunk/src/zmi/core/error/texttbentry.pt	2009-06-07 15:25:32 UTC (rev 100692)
@@ -0,0 +1,9 @@
+<html>
+<body>
+ <div tal:define="entry python:context.getLogEntryById(request.get('id'))">
+  <pre tal:content="entry/tb_text">
+        Traceback (text)
+  </pre>
+ </div>
+</body>
+</html>



More information about the Checkins mailing list