[Zope3-checkins] CVS: Zope3/src/zope/app/exception/browser -
__init__.py:1.1 configure.zcml:1.1 default.pt:1.1 form.py:1.1
notfound.pt:1.1 unauthorized.pt:1.1 unauthorized.py:1.1
user.pt:1.1 user.py:1.1
Stephan Richter
srichter at cosmos.phy.tufts.edu
Sat Mar 13 23:44:53 EST 2004
Update of /cvs-repository/Zope3/src/zope/app/exception/browser
In directory cvs.zope.org:/tmp/cvs-serv2821/src/zope/app/exception/browser
Added Files:
__init__.py configure.zcml default.pt form.py notfound.pt
unauthorized.pt unauthorized.py user.pt user.py
Log Message:
Move exception views and interfaces to their own package zope.app.exception.
=== Added File Zope3/src/zope/app/exception/browser/__init__.py ===
# empty __init__.py file to make this directory into a package
=== Added File Zope3/src/zope/app/exception/browser/configure.zcml ===
<zope:configure
xmlns:zope="http://namespaces.zope.org/zope"
xmlns="http://namespaces.zope.org/browser">
<page
for="zope.interface.common.interfaces.IException"
name="index.html"
template="default.pt"
permission="zope.Public"
/>
<page
for="zope.exceptions.IUnauthorized"
name="index.html"
permission="zope.Public"
template="unauthorized.pt"
class=".unauthorized.Unauthorized"
/>
<page
for="zope.app.exception.interfaces.IUserError"
name="index.html"
permission="zope.Public"
template="user.pt"
class=".user.UserErrorView"
/>
<page
for="zope.app.form.interfaces.IWidgetInputError"
name="snippet"
permission="zope.Public"
class=".form.WidgetInputErrorView"
attribute="snippet"
/>
<page
for="zope.publisher.interfaces.NotFound"
name="index.html"
permission="zope.Public"
template="notfound.pt"
/>
</zope:configure>
=== Added File Zope3/src/zope/app/exception/browser/default.pt ===
<html><title>System Error</title>
<body>
A system error occurred.
</body>
</html>
=== Added File Zope3/src/zope/app/exception/browser/form.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.
#
##############################################################################
"""Form-related exception views
$Id: form.py,v 1.1 2004/03/14 04:44:51 srichter Exp $
"""
from zope.app.form.interfaces import IWidgetInputError
from cgi import escape
class WidgetInputErrorView:
"""Displat an input error as a snippet of text"""
__used_for__ = IWidgetInputError
def __init__(self, context, request):
self.context, self.request = context, request
def snippet(self):
"""Convert a widget input error to an html snippet
>>> from zope.app.form.interfaces import WidgetInputError
>>> err = WidgetInputError("foo", "Foo", ["Foo input < 1"])
>>> view = WidgetInputErrorView(err, None)
>>> view.snippet()
'<span class="error">Foo input < 1</span>'
"""
return '<span class="error">%s</span>' % escape(self.context.errors[0])
=== Added File Zope3/src/zope/app/exception/browser/notfound.pt ===
<html metal:use-macro="context/@@standard_macros/dialog">
<body>
<div metal:fill-slot="body">
<h3 i18n:translate="">
The page that you are trying to access is not available
</h3>
<br/>
<b i18n:translate="">Please note the following:</b>
<br/>
<ol>
<li i18n:translate=""> You might have miss-spelled the url </li>
<li i18n:translate="">
You might be trying to access a non-existing page
</li>
</ol>
</div>
</body>
</html>
=== Added File Zope3/src/zope/app/exception/browser/unauthorized.pt ===
<tal:Make_sure_we_process_the_authorization_challenge_first
condition="view/issueChallenge"
/><html metal:use-macro="context/@@standard_macros/page">
<body>
<div metal:fill-slot="body">
<h1 i18n:translate="">Unauthorized</h1>
<p tal:content="context"/>
</div>
</body>
</html>
=== Added File Zope3/src/zope/app/exception/browser/unauthorized.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.
#
##############################################################################
"""Unautorized Exception View Class
$Id: unauthorized.py,v 1.1 2004/03/14 04:44:51 srichter Exp $
"""
from zope.app import zapi
from zope.app.security.interfaces import IAuthenticationService
class Unauthorized(object):
def issueChallenge(self):
# Set the error status to 403 (Forbidden) in the case when we don't
# challenge the user
self.request.response.setStatus(403)
principal = self.request.user
prinreg = zapi.getParent(principal)
if not IAuthenticationService.providedBy(prinreg):
# With PluggableAuthenticationService, principals are
# contained in the PrincipalSource, which is contained in
# the service.
prinreg = zapi.getParent(prinreg)
assert IAuthenticationService.providedBy(prinreg)
prinreg.unauthorized(principal.id, self.request)
=== Added File Zope3/src/zope/app/exception/browser/user.pt ===
<html metal:use-macro="context/@@standard_macros/page">
<body>
<div metal:fill-slot="body">
<ul>
<li tal:repeat="part context" tal:content="part">Error message</li>
</ul>
</div>
</body>
</html>
=== Added File Zope3/src/zope/app/exception/browser/user.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.
##############################################################################
"""Support for user views
$Id: user.py,v 1.1 2004/03/14 04:44:51 srichter Exp $
"""
__metaclass__ = type
class UserErrorView:
def title(self):
return self.context.__class__.__name__
More information about the Zope3-Checkins
mailing list