[Zope3-checkins] CVS: Zope3/src/zope/app/errorservice/browser - __init__.py:1.1 configure.zcml:1.1 error.gif:1.1 error.pt:1.1 error_config.pt:1.1 error_service.gif:1.1 errorentry.pt:1.1 texttbentry.pt:1.1

Stephan Richter srichter at cosmos.phy.tufts.edu
Wed Mar 10 08:43:37 EST 2004


Update of /cvs-repository/Zope3/src/zope/app/errorservice/browser
In directory cvs.zope.org:/tmp/cvs-serv4477/src/zope/app/errorservice/browser

Added Files:
	__init__.py configure.zcml error.gif error.pt error_config.pt 
	error_service.gif errorentry.pt texttbentry.pt 
Log Message:


Moved error reporting service to zope.app.errorservice. Provided
modulealiases, so that your old ZODB will still work.


=== Added File Zope3/src/zope/app/errorservice/browser/__init__.py ===
##############################################################################
#
# 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.0 (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 service control.

$Id: __init__.py,v 1.1 2004/03/10 13:43:36 srichter Exp $
"""
from zope.publisher.browser import BrowserView

from zope.app import zapi
from zope.app.services.servicenames import ErrorLogging
from zope.app.errorservice.interfaces import ILocalErrorReportingService

class EditErrorLog:
    __used_for__ = ILocalErrorReportingService

    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 ++site++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 = zapi.getService(self, ErrorLogging)
            url = str(zapi.getView(err, 'absolute_url', self.request))
            url = url + "/@@SelectedManagementView.html"
        except TypeError:
            siterooturl = self.request.getApplicationURL()
            url = siterooturl + "/@@errorRedirect.html"

        self.request.response.redirect(url)



=== Added File Zope3/src/zope/app/errorservice/browser/configure.zcml ===
<zope:configure
    xmlns:zope="http://namespaces.zope.org/zope"
    xmlns="http://namespaces.zope.org/browser">

  <pages
      for="*"
      permission="zope.ManageContent"
      class=".ErrorRedirect" >

    <page name="errorRedirect.html" attribute="action" />
  </pages>

  <menuItem
      for="*"
      menu="zmi_actions"
      title="Errors"
      action="@@errorRedirect.html" />

  <!--Error Logging Service -->

  <pages
      for="zope.app.errorservice.interfaces.IErrorReportingService"
      permission="zope.Public"
      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.app.errorservice.ErrorReportingService"
     title="Error Logging Service"
     description="Error Reporting Service for Logging Errors"
     permission="zope.ManageServices" />

  <icon name="zmi_icon"
      for="zope.app.errorservice.interfaces.IErrorReportingService"
      file="error_service.gif" />

</zope:configure>



=== Added File Zope3/src/zope/app/errorservice/browser/error.gif ===
  <Binary-ish file>

=== Added File Zope3/src/zope/app/errorservice/browser/error.pt ===
<html metal:use-macro="views/standard_macros/page">
<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">
        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 File Zope3/src/zope/app/errorservice/browser/error_config.pt ===
<html metal:use-macro="views/standard_macros/page">
<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 File Zope3/src/zope/app/errorservice/browser/error_service.gif ===
  <Binary-ish file>

=== Added File Zope3/src/zope/app/errorservice/browser/errorentry.pt ===
<html metal:use-macro="views/standard_macros/page">
<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">
    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 File Zope3/src/zope/app/errorservice/browser/texttbentry.pt ===
<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 Zope3-Checkins mailing list