From 1db5469c9c189a1f5480e7f61e308a0179a2bd42 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Sun, 31 May 2009 16:52:41 +0000 Subject: - Remove ``repoze.bfg.wsgi.HTTPException``, ``repoze.bfg.wsgi.NotFound``, and ``repoze.bfg.wsgi.Unauthorized``. These classes were disused with the introduction of the ``IUnauthorizedView`` and ``INotFoundView`` machinery. --- CHANGES.txt | 5 +++ repoze/bfg/tests/test_wsgi.py | 77 ------------------------------------------- repoze/bfg/threadlocal.py | 1 - repoze/bfg/wsgi.py | 24 -------------- 4 files changed, 5 insertions(+), 102 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 071b7f2df..988d2f433 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -7,6 +7,11 @@ Removals - Remove ``repoze.bfg.threadlocal.setManager``. It was only used in unit tests. +- Remove ``repoze.bfg.wsgi.HTTPException``, + ``repoze.bfg.wsgi.NotFound``, and ``repoze.bfg.wsgi.Unauthorized``. + These classes were disused with the introduction of the + ``IUnauthorizedView`` and ``INotFoundView`` machinery. + Documentation ------------- diff --git a/repoze/bfg/tests/test_wsgi.py b/repoze/bfg/tests/test_wsgi.py index 893364635..9d8a85630 100644 --- a/repoze/bfg/tests/test_wsgi.py +++ b/repoze/bfg/tests/test_wsgi.py @@ -109,76 +109,6 @@ class WSGIApp2Tests(unittest.TestCase): self.assertEqual(request.environ['PATH_INFO'], '/') self.assertEqual(request.environ['SCRIPT_NAME'], '') -class TestNotFound(unittest.TestCase): - def _getTargetClass(self): - from repoze.bfg.wsgi import NotFound - return NotFound - - def _makeOne(self): - return self._getTargetClass()() - - def test_no_message(self): - environ = {} - L = [] - def start_response(status, headers): - L.append((status, headers)) - app = self._makeOne() - result = app(environ, start_response) - self.assertEqual(len(result), 1) - self.failUnless('404 Not Found' in result[0]) - self.assertEqual(L[0][0], '404 Not Found') - self.assertEqual(L[0][1], [('Content-Length', str(len(result[0]))), - ('Content-Type', 'text/html')]) - - def test_with_message(self): - environ = {'repoze.bfg.message':''} - L = [] - def start_response(status, headers): - L.append((status, headers)) - app = self._makeOne() - result = app(environ, start_response) - self.assertEqual(len(result), 1) - self.failUnless('404 Not Found' in result[0]) - self.failUnless('<hi!>' in result[0]) - self.assertEqual(L[0][0], '404 Not Found') - self.assertEqual(L[0][1], [('Content-Length', str(len(result[0]))), - ('Content-Type', 'text/html')]) - -class TestUnauthorized(unittest.TestCase): - def _getTargetClass(self): - from repoze.bfg.wsgi import Unauthorized - return Unauthorized - - def _makeOne(self): - return self._getTargetClass()() - - def test_no_message(self): - environ = {} - L = [] - def start_response(status, headers): - L.append((status, headers)) - app = self._makeOne() - result = app(environ, start_response) - self.assertEqual(len(result), 1) - self.failUnless('401 Unauthorized' in result[0]) - self.assertEqual(L[0][0], '401 Unauthorized') - self.assertEqual(L[0][1], [('Content-Length', str(len(result[0]))), - ('Content-Type', 'text/html')]) - - def test_with_message(self): - environ = {'repoze.bfg.message':''} - L = [] - def start_response(status, headers): - L.append((status, headers)) - app = self._makeOne() - result = app(environ, start_response) - self.assertEqual(len(result), 1) - self.failUnless('401 Unauthorized' in result[0]) - self.failUnless('<hi!>' in result[0]) - self.assertEqual(L[0][0], '401 Unauthorized') - self.assertEqual(L[0][1], [('Content-Length', str(len(result[0]))), - ('Content-Type', 'text/html')]) - def dummyapp(environ, start_response): """ """ @@ -188,10 +118,3 @@ class DummyContext: class DummyRequest: def get_response(self, application): return application - - - - - - - diff --git a/repoze/bfg/threadlocal.py b/repoze/bfg/threadlocal.py index b35be187b..613ea4b65 100644 --- a/repoze/bfg/threadlocal.py +++ b/repoze/bfg/threadlocal.py @@ -31,4 +31,3 @@ def defaults(): return defaults manager = ThreadLocalManager(defaults) - diff --git a/repoze/bfg/wsgi.py b/repoze/bfg/wsgi.py index 027345673..a04be9e97 100644 --- a/repoze/bfg/wsgi.py +++ b/repoze/bfg/wsgi.py @@ -1,5 +1,3 @@ -from cgi import escape - try: from functools import wraps except ImportError: #pragma NO COVERAGE @@ -102,25 +100,3 @@ def wsgiapp2(wrapped): return request.get_response(wrapped) return wraps(wrapped)(decorator) # grokkability -class HTTPException(object): - def __call__(self, environ, start_response, exc_info=False): - try: - msg = escape(environ['repoze.bfg.message']) - except KeyError: - msg = '' - html = """ - %s

%s

- %s - """ % (self.status, self.status, msg) - headers = [('Content-Length', str(len(html))), - ('Content-Type', 'text/html')] - start_response(self.status, headers) - return [html] - -class NotFound(HTTPException): - """ The default NotFound WSGI application """ - status = '404 Not Found' - -class Unauthorized(HTTPException): - """ The default Unauthorized WSGI application """ - status = '401 Unauthorized' -- cgit v1.2.3