[Zope-Checkins] SVN: Zope/branches/2.12/ - LP #143946: Provide a more informative error message when a
Jens Vagelpohl
jens at dataflake.org
Wed Jun 16 06:04:55 EDT 2010
Log message for revision 113513:
- LP #143946: Provide a more informative error message when a
WebDAV PUT fails.
Changed:
U Zope/branches/2.12/doc/CHANGES.rst
U Zope/branches/2.12/src/webdav/NullResource.py
U Zope/branches/2.12/src/webdav/tests/testNullResource.py
-=-
Modified: Zope/branches/2.12/doc/CHANGES.rst
===================================================================
--- Zope/branches/2.12/doc/CHANGES.rst 2010-06-16 09:57:35 UTC (rev 113512)
+++ Zope/branches/2.12/doc/CHANGES.rst 2010-06-16 10:04:54 UTC (rev 113513)
@@ -11,6 +11,8 @@
Bugs Fixed
++++++++++
+- LP #143946: Provide a more informative error message when a
+ WebDAV PUT fails.
2.12.7 (2010-06-13)
Modified: Zope/branches/2.12/src/webdav/NullResource.py
===================================================================
--- Zope/branches/2.12/src/webdav/NullResource.py 2010-06-16 09:57:35 UTC (rev 113512)
+++ Zope/branches/2.12/src/webdav/NullResource.py 2010-06-16 10:04:54 UTC (rev 113513)
@@ -166,7 +166,9 @@
try:
parent._verifyObjectPaste(ob.__of__(parent), 0)
except CopyError:
- raise Unauthorized, sys.exc_info()[1]
+ sMsg = 'Unable to create object of class %s in %s: %s' % \
+ (ob.__class__, repr(parent), sys.exc_info()[1],)
+ raise Unauthorized, sMsg
# Delegate actual PUT handling to the new object,
# SDS: But just *after* it has been stored.
Modified: Zope/branches/2.12/src/webdav/tests/testNullResource.py
===================================================================
--- Zope/branches/2.12/src/webdav/tests/testNullResource.py 2010-06-16 09:57:35 UTC (rev 113512)
+++ Zope/branches/2.12/src/webdav/tests/testNullResource.py 2010-06-16 10:04:54 UTC (rev 113513)
@@ -48,7 +48,34 @@
self.assertEqual(response.body, '')
self.failUnless(response.locked)
+ def test_PUT_unauthorized_message(self):
+ # See https://bugs.launchpad.net/bugs/143946
+ import ExtensionClass
+ from OFS.CopySupport import CopyError
+ from zExceptions import Unauthorized
+ class DummyRequest:
+ def get_header(self, header, default=''):
+ return default
+ def get(self, name, default=None):
+ return default
+ class DummyResponse:
+ _server_version = 'Dummy' # emulate ZServer response
+ def setHeader(self, *args):
+ pass
+ class DummyParent(ExtensionClass.Base):
+ def _verifyObjectPaste(self, *args, **kw):
+ raise CopyError('Bad Boy!')
+ nonesuch = self._makeOne()
+ nonesuch.__parent__ = DummyParent()
+ request = DummyRequest()
+ response = DummyResponse()
+ try:
+ nonesuch.PUT(request, response)
+ except Unauthorized, e:
+ self.failUnless(str(e).startswith('Unable to create object'))
+
+
def test_suite():
return unittest.TestSuite((
unittest.makeSuite(TestLockNullResource),
More information about the Zope-Checkins
mailing list