[Zope-Checkins] SVN: Zope/trunk/lib/python/ZPublisher/ Collector
#2136: Map ResourceLockedError to the correct response code.
Tres Seaver
cvs-admin at zope.org
Wed Jun 21 12:50:50 EDT 2006
Log message for revision 68781:
Collector #2136: Map ResourceLockedError to the correct response code.
Changed:
U Zope/trunk/lib/python/ZPublisher/HTTPResponse.py
U Zope/trunk/lib/python/ZPublisher/tests/testHTTPResponse.py
-=-
Modified: Zope/trunk/lib/python/ZPublisher/HTTPResponse.py
===================================================================
--- Zope/trunk/lib/python/ZPublisher/HTTPResponse.py 2006-06-21 16:50:26 UTC (rev 68780)
+++ Zope/trunk/lib/python/ZPublisher/HTTPResponse.py 2006-06-21 16:50:46 UTC (rev 68781)
@@ -97,6 +97,7 @@
status_codes['nameerror'] = 503
status_codes['keyerror'] = 503
status_codes['redirect'] = 300
+status_codes['resourcelockederror'] = 423
start_of_header_search = re.compile('(<head[^>]*>)', re.IGNORECASE).search
Modified: Zope/trunk/lib/python/ZPublisher/tests/testHTTPResponse.py
===================================================================
--- Zope/trunk/lib/python/ZPublisher/tests/testHTTPResponse.py 2006-06-21 16:50:26 UTC (rev 68780)
+++ Zope/trunk/lib/python/ZPublisher/tests/testHTTPResponse.py 2006-06-21 16:50:46 UTC (rev 68781)
@@ -51,7 +51,8 @@
# Verify that the cookie is expired even if an expires kw arg is passed
# http://zope.org/Collectors/Zope/1160
response = self._makeOne()
- response.expireCookie('foo', path='/', expires='Mon, 22-Mar-2004 17:59 GMT', max_age=99)
+ response.expireCookie('foo', path='/',
+ expires='Mon, 22-Mar-2004 17:59 GMT', max_age=99)
cookie = response.cookies.get('foo', None)
self.failUnless(cookie)
self.assertEqual(cookie.get('expires'), 'Wed, 31-Dec-97 23:59:59 GMT')
@@ -76,27 +77,43 @@
response.appendHeader('XXX', 'foo')
self.assertEqual(response.headers.get('xxx'), 'bar,\n\tfoo')
- def test_CharsetNoHeader(self):
+ def test_setStatus_ResourceLockedError(self):
+ response = self._makeOne()
+ from webdav.Lockable import ResourceLockedError
+ response.setStatus(ResourceLockedError)
+ self.assertEqual(response.status, 423)
+
+ def test_charset_no_header(self):
response = self._makeOne(body='foo')
- self.assertEqual(response.headers.get('content-type'), 'text/plain; charset=iso-8859-15')
+ self.assertEqual(response.headers.get('content-type'),
+ 'text/plain; charset=iso-8859-15')
- def test_CharsetTextHeader(self):
- response = self._makeOne(body='foo', headers={'content-type': 'text/plain'})
- self.assertEqual(response.headers.get('content-type'), 'text/plain; charset=iso-8859-15')
+ def test_charset_text_header(self):
+ response = self._makeOne(body='foo',
+ headers={'content-type': 'text/plain'})
+ self.assertEqual(response.headers.get('content-type'),
+ 'text/plain; charset=iso-8859-15')
- def test_CharsetApplicationHeader(self):
- response = self._makeOne(body='foo', headers={'content-type': 'application/foo'})
- self.assertEqual(response.headers.get('content-type'), 'application/foo; charset=iso-8859-15')
+ def test_charset_application_header(self):
+ response = self._makeOne(body='foo',
+ headers={'content-type': 'application/foo'})
+ self.assertEqual(response.headers.get('content-type'),
+ 'application/foo; charset=iso-8859-15')
- def test_CharsetApplicationHeaderUnicode(self):
- response = self._makeOne(body=unicode('ärger', 'iso-8859-15'), headers={'content-type': 'application/foo'})
- self.assertEqual(response.headers.get('content-type'), 'application/foo; charset=iso-8859-15')
+ def test_charset_application_header_unicode(self):
+ response = self._makeOne(body=unicode('ärger', 'iso-8859-15'),
+ headers={'content-type': 'application/foo'})
+ self.assertEqual(response.headers.get('content-type'),
+ 'application/foo; charset=iso-8859-15')
self.assertEqual(response.body, 'ärger')
- def test_CharsetApplicationHeader1Unicode(self):
- response = self._makeOne(body=unicode('ärger', 'iso-8859-15'), headers={'content-type': 'application/foo; charset=utf-8'})
- self.assertEqual(response.headers.get('content-type'), 'application/foo; charset=utf-8')
- self.assertEqual(response.body, unicode('ärger', 'iso-8859-15').encode('utf-8'))
+ def test_charset_application_header_unicode_1(self):
+ response = self._makeOne(body=unicode('ärger', 'iso-8859-15'),
+ headers={'content-type': 'application/foo; charset=utf-8'})
+ self.assertEqual(response.headers.get('content-type'),
+ 'application/foo; charset=utf-8')
+ self.assertEqual(response.body, unicode('ärger',
+ 'iso-8859-15').encode('utf-8'))
def test_XMLEncodingRecoding(self):
xml = u'<?xml version="1.0" encoding="iso-8859-15" ?>\n<foo><bar/></foo>'
More information about the Zope-Checkins
mailing list