[Zope-Checkins] SVN: Zope/trunk/ - LP #143946: Provide a more informative error message when a

Jens Vagelpohl jens at dataflake.org
Wed Jun 16 06:19:32 EDT 2010


Log message for revision 113514:
  - LP #143946: Provide a more informative error message when a
    WebDAV PUT fails.
  

Changed:
  U   Zope/trunk/doc/CHANGES.rst
  U   Zope/trunk/src/webdav/NullResource.py
  U   Zope/trunk/src/webdav/tests/testNullResource.py

-=-
Modified: Zope/trunk/doc/CHANGES.rst
===================================================================
--- Zope/trunk/doc/CHANGES.rst	2010-06-16 10:04:54 UTC (rev 113513)
+++ Zope/trunk/doc/CHANGES.rst	2010-06-16 10:19:32 UTC (rev 113514)
@@ -181,6 +181,9 @@
 Bugs Fixed
 ++++++++++
 
+- LP #143946: Provide a more informative error message when a
+  WebDAV PUT fails.
+
 - LP #143261: The (very old-fashioned) Zope2.debug interactive request
   debugger still referred to the toplevel module ``Zope``, which was
   renamed to ``Zope2`` a long time ago.

Modified: Zope/trunk/src/webdav/NullResource.py
===================================================================
--- Zope/trunk/src/webdav/NullResource.py	2010-06-16 10:04:54 UTC (rev 113513)
+++ Zope/trunk/src/webdav/NullResource.py	2010-06-16 10:19:32 UTC (rev 113514)
@@ -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/trunk/src/webdav/tests/testNullResource.py
===================================================================
--- Zope/trunk/src/webdav/tests/testNullResource.py	2010-06-16 10:04:54 UTC (rev 113513)
+++ Zope/trunk/src/webdav/tests/testNullResource.py	2010-06-16 10:19:32 UTC (rev 113514)
@@ -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