Commit e957923e authored by Jens Vagelpohl's avatar Jens Vagelpohl

- LP #143946: Provide a more informative error message when a

  WebDAV PUT fails.
parent df3f7661
......@@ -11,6 +11,8 @@ http://docs.zope.org/zope2/releases/.
Bugs Fixed
++++++++++
- LP #143946: Provide a more informative error message when a
WebDAV PUT fails.
2.12.7 (2010-06-13)
......
......@@ -166,7 +166,9 @@ class NullResource(Persistent, Implicit, Resource):
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.
......
......@@ -48,6 +48,33 @@ class TestNullResource(unittest.TestCase):
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((
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment