[Zope-Checkins] SVN: Zope/trunk/lib/python/webdav/ Forward port fix
for LP #239636 from 2.9 branch.
Tres Seaver
tseaver at palladion.com
Sat Jun 14 13:52:53 EDT 2008
Log message for revision 87400:
Forward port fix for LP #239636 from 2.9 branch.
Changed:
U Zope/trunk/lib/python/webdav/NullResource.py
U Zope/trunk/lib/python/webdav/tests/testNullResource.py
-=-
Modified: Zope/trunk/lib/python/webdav/NullResource.py
===================================================================
--- Zope/trunk/lib/python/webdav/NullResource.py 2008-06-14 17:52:08 UTC (rev 87399)
+++ Zope/trunk/lib/python/webdav/NullResource.py 2008-06-14 17:52:52 UTC (rev 87400)
@@ -69,6 +69,7 @@
def HEAD(self, REQUEST, RESPONSE):
"""Retrieve resource information without a response message body."""
self.dav__init(REQUEST, RESPONSE)
+ RESPONSE.setBody('', lock=True)
raise NotFound, 'The requested resource does not exist.'
# Most methods return 404 (Not Found) for null resources.
Modified: Zope/trunk/lib/python/webdav/tests/testNullResource.py
===================================================================
--- Zope/trunk/lib/python/webdav/tests/testNullResource.py 2008-06-14 17:52:08 UTC (rev 87399)
+++ Zope/trunk/lib/python/webdav/tests/testNullResource.py 2008-06-14 17:52:52 UTC (rev 87400)
@@ -13,14 +13,42 @@
class TestNullResource(unittest.TestCase):
+ def _getTargetClass(self):
+ from webdav.NullResource import NullResource
+ return NullResource
+
+ def _makeOne(self, parent=None, name='nonesuch', **kw):
+ return self._getTargetClass()(parent, name, **kw)
+
def test_z3interfaces(self):
from webdav.interfaces import IWriteLock
- from webdav.NullResource import NullResource
from zope.interface.verify import verifyClass
- verifyClass(IWriteLock, NullResource)
+ verifyClass(IWriteLock, self._getTargetClass())
+ def test_HEAD_locks_empty_body_before_raising_NotFound(self):
+ from zExceptions import NotFound
+ # See https://bugs.launchpad.net/bugs/239636
+ class DummyResponse:
+ _server_version = 'Dummy' # emulate ZServer response
+ locked = False
+ body = None
+ def setHeader(self, *args):
+ pass
+ def setBody(self, body, lock=False):
+ self.body = body
+ self.locked = bool(lock)
+ nonesuch = self._makeOne()
+ request = {}
+ response = DummyResponse()
+
+ self.assertRaises(NotFound, nonesuch.HEAD, request, response)
+
+ self.assertEqual(response.body, '')
+ self.failUnless(response.locked)
+
+
def test_suite():
return unittest.TestSuite((
unittest.makeSuite(TestLockNullResource),
More information about the Zope-Checkins
mailing list