[Zope3-checkins] CVS: Zope3/src/zope/app/debugskin - __init__.py:1.1 configure.zcml:1.1 error_debug.pt:1.1 exceptions.py:1.1 tests.py:1.1 unauthorized.pt:1.1

Philipp von Weitershausen philikon at philikon.de
Tue Mar 2 12:11:30 EST 2004


Update of /cvs-repository/Zope3/src/zope/app/debugskin
In directory cvs.zope.org:/tmp/cvs-serv20275/debugskin

Added Files:
	__init__.py configure.zcml error_debug.pt exceptions.py 
	tests.py unauthorized.pt 
Log Message:
Moved browser skins to their individual packages below zope.app.


=== Added File Zope3/src/zope/app/debugskin/__init__.py ===
##

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

  <layer name="debug" />
  <skin name="Debug" layers="debug rotterdam default" />

  <page
      for="zope.exceptions.IUnauthorized"
      name="index.html"
      permission="zope.Public"
      template="unauthorized.pt"
      class="zope.app.browser.exception.unauthorized.Unauthorized"
      layer="debug" />

  <page 
      name="index.html"
      template="error_debug.pt"
      for="zope.interface.common.interfaces.IException"
      class=".exceptions.ExceptionDebugView"
      permission="zope.Public"
      layer="debug" />

</zope:configure>



=== Added File Zope3/src/zope/app/debugskin/error_debug.pt ===
<html metal:use-macro="context/@@standard_macros/dialog">
<body>
<div metal:fill-slot="body">

  <h3 i18n:translate="">
    Error type: 
    <tal:span tal:replace="view/error_type" i18n:name="error_type"/>
  </h3>

  <h5 i18n:translate="">
    Error object: 
    <tal:span tal:replace="view/error_object" i18n:name="error_object"/>
  </h5>

  <pre class="traceback">
    <tal:line tal:repeat="line view/traceback_lines"
              tal:replace="line">TRACEBACK LINE</tal:line>
  </pre>

</div>
</body>
</html>



=== Added File Zope3/src/zope/app/debugskin/exceptions.py ===
##############################################################################
#
# Copyright (c) 2003 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.
#
##############################################################################
"""View that renders a traceback for exceptions.

$Id: exceptions.py,v 1.1 2004/03/02 17:11:29 philikon Exp $
"""
import sys
import traceback

from zope.interface.common.interfaces import IException

__metaclass__ = type


class ExceptionDebugView:
    """ Render exceptions for debugging."""
    __used_for__ = IException

    def __init__(self, context, request):

        self.context = context
        self.request = request

        self.error_type, self.error_object, tb = sys.exc_info()
        try:
            self.traceback_lines = traceback.format_tb(tb)
        finally:
            del tb


=== Added File Zope3/src/zope/app/debugskin/tests.py ===
##############################################################################
#
# Copyright (c) 2003 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.
#
##############################################################################
""" Unit tests for the 'exceptions' view.

$Id: tests.py,v 1.1 2004/03/02 17:11:29 philikon Exp $
"""

from unittest import TestCase, TestLoader, TextTestRunner
from zope.app.debugskin.exceptions import ExceptionDebugView

class TestExceptions(TestCase):
    
    def _getTargetClass(self):
        return ExceptionDebugView

    def _makeOne(self, *args, **kw):
        return self._getTargetClass()(*args, **kw)

    def test_tracebackLines(self):
        import sys
        import traceback
        try:
            1/0
        except:
            context = sys.exc_info()[0]
            request = None
            view = self._makeOne(context, request)
            self.assertEqual(view.error_type, sys.exc_info()[0])
            self.assertEqual(view.error_object, sys.exc_info()[1])
            tb_lines = traceback.extract_tb(sys.exc_info()[2])
            self.assertEqual(len(view.traceback_lines), len(tb_lines))

def test_suite():
    loader = TestLoader()
    return loader.loadTestsFromTestCase(TestExceptions)

if __name__=='__main__':
    TextTestRunner().run(test_suite())



=== Added File Zope3/src/zope/app/debugskin/unauthorized.pt ===
<tal:Make_sure_we_process_the_authorization_chalenge_first
    condition="view/issueChallenge"/><html 
    metal:use-macro="context/@@standard_macros/dialog">
<body>
<div metal:fill-slot="body">

  <h1 i18n:translate="">Unauthorized</h1>
  <p i18n:translate="">You're not allowed in here.</p>

</div>
</body>
</html>




More information about the Zope3-Checkins mailing list