[Checkins] SVN: Sandbox/janwijbrand/zope.errorview/trunk/s start renaming modules and views, prepare for browser-based views as opposed to the http-based views
Jan-Wijbrand Kolman
janwijbrand at gmail.com
Wed Jan 19 05:24:30 EST 2011
Log message for revision 119692:
start renaming modules and views, prepare for browser-based views as opposed to the http-based views
Changed:
U Sandbox/janwijbrand/zope.errorview/trunk/setup.py
U Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/__init__.py
A Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/browser.zcml
D Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/errorview.zcml
A Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/http.py
A Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/http.zcml
D Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/methodnotallowed.py
D Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/notfound.py
A Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/tests/test_exceptionview.py
D Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/tests/test_methodnotallowed.py
D Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/tests/test_unauthorized.py
D Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/unauthorized.py
-=-
Modified: Sandbox/janwijbrand/zope.errorview/trunk/setup.py
===================================================================
--- Sandbox/janwijbrand/zope.errorview/trunk/setup.py 2011-01-19 09:45:04 UTC (rev 119691)
+++ Sandbox/janwijbrand/zope.errorview/trunk/setup.py 2011-01-19 10:24:30 UTC (rev 119692)
@@ -50,9 +50,12 @@
packages=find_packages('src'),
package_dir={'': 'src'},
namespace_packages=['zope'],
- extras_require={'test':[]},
+ extras_require={
+ 'test':[],
+ },
install_requires=[
'setuptools',
+ 'zope.browser',
'zope.component',
'zope.interface',
'zope.publisher',
Modified: Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/__init__.py
===================================================================
--- Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/__init__.py 2011-01-19 09:45:04 UTC (rev 119691)
+++ Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/__init__.py 2011-01-19 10:24:30 UTC (rev 119692)
@@ -1 +1 @@
-# empty __init__.py file to make this directory into a package
+# a package
Copied: Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/browser.zcml (from rev 119660, Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/errorview.zcml)
===================================================================
--- Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/browser.zcml (rev 0)
+++ Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/browser.zcml 2011-01-19 10:24:30 UTC (rev 119692)
@@ -0,0 +1,7 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:browser="http://namespaces.zope.org/browser">
+
+ <include package="." file="http.zcml" />
+
+</configure>
Deleted: Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/errorview.zcml
===================================================================
--- Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/errorview.zcml 2011-01-19 09:45:04 UTC (rev 119691)
+++ Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/errorview.zcml 2011-01-19 10:24:30 UTC (rev 119692)
@@ -1,50 +0,0 @@
-<configure
- xmlns="http://namespaces.zope.org/zope"
- xmlns:browser="http://namespaces.zope.org/browser">
-
- <include package="zope.component" file="meta.zcml" />
- <include package="zope.publisher" file="meta.zcml" />
-
- <view
- for="zope.security.interfaces.IUnauthorized"
- type="zope.publisher.interfaces.http.IHTTPRequest"
- name="index.html"
- permission="zope.Public"
- factory=".unauthorized.Unauthorized"
- />
-
- <browser:defaultView
- for="zope.security.interfaces.IUnauthorized"
- layer="zope.publisher.interfaces.http.IHTTPRequest"
- name="index.html"
- />
-
- <view
- for="zope.publisher.interfaces.ITraversalException"
- type="zope.publisher.interfaces.http.IHTTPRequest"
- name="index.html"
- permission="zope.Public"
- factory=".notfound.NotFound"
- />
-
- <browser:defaultView
- for="zope.publisher.interfaces.ITraversalException"
- layer="zope.publisher.interfaces.http.IHTTPRequest"
- name="index.html"
- />
-
- <view
- for="zope.publisher.interfaces.http.IMethodNotAllowed"
- factory="zope.errorview.methodnotallowed.MethodNotAllowedView"
- name="index.html"
- type="zope.publisher.interfaces.http.IHTTPRequest"
- permission="zope.Public"
- />
-
- <browser:defaultView
- for="zope.publisher.interfaces.http.IMethodNotAllowed"
- layer="zope.publisher.interfaces.http.IHTTPRequest"
- name="index.html"
- />
-
-</configure>
Added: Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/http.py
===================================================================
--- Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/http.py (rev 0)
+++ Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/http.py 2011-01-19 10:24:30 UTC (rev 119692)
@@ -0,0 +1,82 @@
+##############################################################################
+#
+# Copyright (c) 2003 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.
+#
+##############################################################################
+"""Unauthorized Exception
+
+$Id: unauthorized.py 100273 2009-05-23 02:20:25Z shane $
+"""
+
+from zope.interface import implements
+from zope.publisher.interfaces.http import IHTTPException
+from zope.browser.interfaces import ISystemErrorView
+from zope.component import getAdapters
+from zope.interface import Interface
+
+class SystemErrorViewMixin:
+
+ implements(ISystemErrorView)
+
+ def isSystemError(self):
+ return True
+
+class ExceptionViewBase(object):
+
+ implements(IHTTPException)
+
+ def __init__(self, context, request):
+ self.context = context
+ self.request = request
+ self.response = request.response
+
+ def __call__(self):
+ self.response.setStatus(500)
+ return ''
+
+ def __str__(self):
+ return self()
+
+class ExceptionView(ExceptionViewBase, SystemErrorViewMixin):
+ pass
+
+class TraversalExceptionView(ExceptionViewBase):
+
+ def __call__(self):
+ if self.request.method =='MKCOL' and self.request.getTraversalStack():
+ # MKCOL with non-existing parent.
+ self.request.response.setStatus(409)
+ else:
+ self.request.response.setStatus(404)
+ return ''
+
+class UnauthorizedView(ExceptionViewBase):
+
+ def __call__(self):
+ self.request.unauthorized('basic realm="Zope"')
+ self.request.response.setStatus(401)
+ return ''
+
+class MethodNotAllowedView(ExceptionViewBase):
+
+ def allowed(self):
+ # XXX how to determine the allowed HTTP methods? XXX we need
+ # a safe way to determine the allow HTTP methods. Or should we
+ # let the application handle it?
+ return []
+
+ def __call__(self):
+ error = self.context
+ allow = self.allowed()
+ self.request.response.setStatus(405)
+ self.request.response.setHeader('Allow', ', '.join(allow))
+ return ''
+
Added: Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/http.zcml
===================================================================
--- Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/http.zcml (rev 0)
+++ Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/http.zcml 2011-01-19 10:24:30 UTC (rev 119692)
@@ -0,0 +1,45 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:browser="http://namespaces.zope.org/browser">
+
+ <include package="zope.component" file="meta.zcml" />
+ <include package="zope.publisher" file="meta.zcml" />
+
+ <view
+ class=".http.ExceptionView"
+ for="zope.interface.common.interfaces.IException"
+ name="index.html"
+ permission="zope.Public"
+ />
+
+<!-- <view-->
+<!-- factory=".unauthorized.Unauthorized"-->
+<!-- for="zope.security.interfaces.IUnauthorized"-->
+<!-- type="zope.publisher.interfaces.http.IHTTPRequest"-->
+<!-- name="index.html"-->
+<!-- permission="zope.Public"-->
+<!-- />-->
+
+<!-- <view-->
+<!-- factory=".notfound.NotFound"-->
+<!-- for="zope.publisher.interfaces.ITraversalException"-->
+<!-- type="zope.publisher.interfaces.http.IHTTPRequest"-->
+<!-- name="index.html"-->
+<!-- permission="zope.Public"-->
+<!-- />-->
+
+<!-- <view-->
+<!-- factory="zope.errorview.methodnotallowed.MethodNotAllowedView"-->
+<!-- for="zope.publisher.interfaces.http.IMethodNotAllowed"-->
+<!-- type="zope.publisher.interfaces.http.IHTTPRequest"-->
+<!-- name="index.html"-->
+<!-- permission="zope.Public"-->
+<!-- />-->
+
+ <browser:defaultView
+ for="zope.interface.common.interfaces.IException"
+ layer="zope.publisher.interfaces.http.IHTTPRequest"
+ name="index.html"
+ />
+
+</configure>
Deleted: Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/methodnotallowed.py
===================================================================
--- Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/methodnotallowed.py 2011-01-19 09:45:04 UTC (rev 119691)
+++ Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/methodnotallowed.py 2011-01-19 10:24:30 UTC (rev 119692)
@@ -1,47 +0,0 @@
-##############################################################################
-# Copyright (c) 2003 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.
-##############################################################################
-"""HTTP 405: Method Not Allowed view
-
-$Id$
-"""
-from zope.component import getAdapters
-from zope.interface import Interface
-from zope.publisher.interfaces.http import IMethodNotAllowed
-
-
-class MethodNotAllowedView(object):
- """A view for MethodNotAllowed that renders a HTTP 405 response."""
-
- __used_for__ = IMethodNotAllowed
-
- def __init__(self, error, request):
- self.error = error
- self.request = request
- allow = []
-
- try:
- # see test_methodnotallowed.TestMethodNotAllowedView.test_defaultView
- # I could not solve this with a while ... next() iterator
- # because it seems like once the generator had an exception it
- # stops returning items
- self.allow = [
- name for name, adapter
- in getAdapters((error.object, error.request), Interface)
- if hasattr(adapter, name)]
- self.allow.sort()
- except TypeError:
- self.allow = []
-
- def __call__(self):
- self.request.response.setHeader('Allow', ', '.join(self.allow))
- self.request.response.setStatus(405)
- return 'Method Not Allowed'
Deleted: Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/notfound.py
===================================================================
--- Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/notfound.py 2011-01-19 09:45:04 UTC (rev 119691)
+++ Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/notfound.py 2011-01-19 10:24:30 UTC (rev 119692)
@@ -1,40 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2003 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.
-#
-##############################################################################
-"""Not found Exception
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-from zope.publisher.interfaces.http import IHTTPException
-from zope.interface import implements
-
-class NotFound(object):
-
- implements(IHTTPException)
-
- def __init__(self, context, request):
- self.context = context
- self.request = request
-
- def __call__(self):
- if self.request.method in ['MKCOL'] and \
- self.request.getTraversalStack():
- # MKCOL with non-existing parent.
- self.request.response.setStatus(409)
- else:
- self.request.response.setStatus(404)
- return ''
-
- __str__ = __call__
Added: Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/tests/test_exceptionview.py
===================================================================
--- Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/tests/test_exceptionview.py (rev 0)
+++ Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/tests/test_exceptionview.py 2011-01-19 10:24:30 UTC (rev 119692)
@@ -0,0 +1,94 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""Unauthorized Exception Test
+
+$Id: test_unauthorized.py 119650 2011-01-18 14:58:35Z janwijbrand $
+"""
+from unittest import TestCase
+from zope.errorview.unauthorized import Unauthorized
+from zope.publisher.browser import TestRequest
+from zope.publisher.interfaces.http import IHTTPException
+from zope.publisher.interfaces.http import MethodNotAllowed
+from zope.security.interfaces import Unauthorized
+from zope.publisher.interfaces import TraversalException
+from zope.errorview import http
+from zope.browser.interfaces import ISystemErrorView
+
+class TestErrorViews(TestCase):
+
+ def setUp(self):
+ self.request = TestRequest()
+
+ def test_exceptionviewbase(self):
+ view = http.ExceptionViewBase(Exception(), self.request)
+ self.failUnless(IHTTPException.providedBy(view))
+ # Render the view.
+ self.assertEquals(str(view), '')
+ self.assertEquals(view(), '')
+ self.assertEqual(self.request.response.getStatus(), 500)
+
+ def test_exceptionview(self):
+ view = http.ExceptionView(Exception(), self.request)
+ self.failUnless(IHTTPException.providedBy(view))
+ self.failUnless(ISystemErrorView.providedBy(view))
+ self.assertTrue(view.isSystemError())
+ # Render the view.
+ self.assertEquals(str(view), '')
+ self.assertEquals(view(), '')
+ self.assertEqual(self.request.response.getStatus(), 500)
+
+ def test_traversalexceptionview(self):
+ view = http.TraversalExceptionView(TraversalException(), self.request)
+ self.failUnless(IHTTPException.providedBy(view))
+ # Render the view.
+ self.assertEquals(str(view), '')
+ self.assertEquals(view(), '')
+ self.assertEqual(self.request.response.getStatus(), 404)
+ # XXX test the MKCOL verb here too.
+
+ def test_unauthorizedexceptionview(self):
+ view = http.UnauthorizedView(Unauthorized(), self.request)
+ self.failUnless(IHTTPException.providedBy(view))
+ # Render the view.
+ self.assertEquals(str(view), '')
+ self.assertEquals(view(), '')
+ self.assertEqual(self.request.response.getStatus(), 401)
+ self.failUnless(
+ self.request.response.getHeader(
+ 'WWW-Authenticate', '', True).startswith('basic'))
+
+ def test_methodnotallowedview(self):
+ error = MethodNotAllowed(object(), self.request)
+ view = http.MethodNotAllowedView(error, self.request)
+ self.failUnless(IHTTPException.providedBy(view))
+ # Render the view.
+ self.assertEquals(str(view), '')
+ self.assertEquals(view(), '')
+ self.assertEquals(self.request.response.getStatus(), 405)
+ self.assertEquals(self.request.response.getHeader('Allow'), '')
+
+ class MyMethodNotAllowedView(http.MethodNotAllowedView):
+ def allowed(self):
+ return 'GET', 'POST', 'PUT', 'DELETE'
+
+ MyMethodNotAllowedView(error, self.request)()
+ self.assertEquals(self.request.response.getStatus(), 405)
+ self.assertEquals(
+ self.request.response.getHeader('Allow'), 'GET, POST, PUT, DELETE')
+
+
+
+
+
+
Deleted: Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/tests/test_methodnotallowed.py
===================================================================
--- Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/tests/test_methodnotallowed.py 2011-01-19 09:45:04 UTC (rev 119691)
+++ Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/tests/test_methodnotallowed.py 2011-01-19 10:24:30 UTC (rev 119692)
@@ -1,91 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2003 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.
-#
-##############################################################################
-"""Tests for HTTP error views
-
-$Id$
-"""
-from unittest import TestCase, TestSuite, main, makeSuite
-from StringIO import StringIO
-
-from zope.component import provideAdapter
-from zope.errorview.methodnotallowed import MethodNotAllowedView
-from zope.interface import Interface, implements
-from zope.publisher.browser import BrowserRequest
-from zope.publisher.http import HTTPRequest
-from zope.publisher.interfaces.browser import IBrowserRequest
-from zope.publisher.interfaces.http import IHTTPRequest, MethodNotAllowed
-from zope.publisher.interfaces import IDefaultViewName
-
-class I(Interface):
- pass
-
-class C(object):
- implements(I)
-
-class GetView(object):
- def __init__(self, context, request):
- pass
- def GET(self):
- pass
-
-class DeleteView(object):
- def __init__(self, context, request):
- pass
- def DELETE(self):
- pass
-
-class TestMethodNotAllowedView(TestCase):
-
- def setUp(self):
- provideAdapter(GetView, (I, IHTTPRequest), Interface, 'GET')
- provideAdapter(DeleteView, (I, IHTTPRequest), Interface, 'DELETE')
- provideAdapter(GetView, (I, IHTTPRequest), Interface, 'irrelevant')
- provideAdapter(DeleteView, (I, IHTTPRequest), Interface, 'also_irr.')
- provideAdapter(u'index.html', (I, IBrowserRequest), IDefaultViewName)
-
- def test(self):
- context = C()
- request = HTTPRequest(StringIO('PUT /bla/bla HTTP/1.1\n\n'), {})
- error = MethodNotAllowed(context, request)
- view = MethodNotAllowedView(error, request)
- result = view()
- self.assertEqual(request.response.getStatus(), 405)
- self.assertEqual(request.response.getHeader('Allow'), 'DELETE, GET')
- self.assertEqual(result, 'Method Not Allowed')
-
- def test_defaultView(self):
- # Do the same with a BrowserRequest edge case is that if someone
- # does a defaultView for the context object but the app is
- # not prepared for webdav or whatever and someone comes with a
- # not allowed method, the exception view fails on getAdapters
- # this might be an issue with zope.publisher, as it provides a
- # unicode object with provideAdapter, but I don't think I can
- # change zope.publisher
- context = C()
- request = BrowserRequest(StringIO('PUT /bla/bla HTTP/1.1\n\n'), {})
- error = MethodNotAllowed(context, request)
- view = MethodNotAllowedView(error, request)
- result = view()
- self.assertEqual(request.response.getStatus(), 405)
- # Well this is empty, but we're grateful that it does not break.
- self.assertEqual(request.response.getHeader('Allow'), '')
- self.assertEqual(result, 'Method Not Allowed')
-
-def test_suite():
- return TestSuite((
- makeSuite(TestMethodNotAllowedView),
- ))
-
-if __name__=='__main__':
- main(defaultTest='test_suite')
Deleted: Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/tests/test_unauthorized.py
===================================================================
--- Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/tests/test_unauthorized.py 2011-01-19 09:45:04 UTC (rev 119691)
+++ Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/tests/test_unauthorized.py 2011-01-19 10:24:30 UTC (rev 119692)
@@ -1,46 +0,0 @@
-##############################################################################
-#
-# 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.
-#
-##############################################################################
-"""Unauthorized Exception Test
-
-$Id$
-"""
-from unittest import TestCase, main, makeSuite
-from zope.errorview.unauthorized import Unauthorized
-from zope.publisher.browser import TestRequest
-from zope.publisher.interfaces.http import IHTTPException
-
-class Test(TestCase):
-
- def testbasicauth(self):
- exception = Exception()
- try:
- raise exception
- except:
- pass
- request = TestRequest()
- u = Unauthorized(exception, request)
- # Check that we implement the right interface.
- self.failUnless(IHTTPException.providedBy(u))
- # Call the view.
- u()
- # Make sure the response status was set.
- self.assertEqual(request.response.getStatus(), 401)
- self.failUnless(request.response.getHeader(
- 'WWW-Authenticate', '', True).startswith('basic'))
-
-def test_suite():
- return makeSuite(Test)
-
-if __name__=='__main__':
- main(defaultTest='test_suite')
Deleted: Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/unauthorized.py
===================================================================
--- Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/unauthorized.py 2011-01-19 09:45:04 UTC (rev 119691)
+++ Sandbox/janwijbrand/zope.errorview/trunk/src/zope/errorview/unauthorized.py 2011-01-19 10:24:30 UTC (rev 119692)
@@ -1,35 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2003 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.
-#
-##############################################################################
-"""Unauthorized Exception
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-from zope.publisher.interfaces.http import IHTTPException
-from zope.interface import implements
-
-class Unauthorized(object):
-
- implements(IHTTPException)
-
- def __init__(self, context, request):
- self.context = context
- self.request = request
-
- def __call__(self):
- self.request.unauthorized('basic realm="Zope"')
- return ''
-
- __str__ = __call__
More information about the checkins
mailing list