[Checkins] SVN: zope.webdav/trunk/src/zope/webdav/ Use the
content-length header instead of the request.read method
Michael Kerrin
michael.kerrin at openapp.biz
Tue Feb 13 14:30:17 EST 2007
Log message for revision 72544:
Use the content-length header instead of the request.read method
to check for message bodies.
Changed:
U zope.webdav/trunk/src/zope/webdav/exceptions/__init__.py
U zope.webdav/trunk/src/zope/webdav/ftests/ftesting.zcml
U zope.webdav/trunk/src/zope/webdav/ftests/test_proppatch.py
U zope.webdav/trunk/src/zope/webdav/mkcol.py
U zope.webdav/trunk/src/zope/webdav/propfind.py
-=-
Modified: zope.webdav/trunk/src/zope/webdav/exceptions/__init__.py
===================================================================
--- zope.webdav/trunk/src/zope/webdav/exceptions/__init__.py 2007-02-13 19:25:25 UTC (rev 72543)
+++ zope.webdav/trunk/src/zope/webdav/exceptions/__init__.py 2007-02-13 19:30:17 UTC (rev 72544)
@@ -34,6 +34,8 @@
class DAVError(object):
interface.implements(zope.webdav.interfaces.IDAVErrorWidget)
+ component.adapts(interface.Interface,
+ zope.webdav.interfaces.IWebDAVRequest)
def __init__(self, context, request):
self.context = context
Modified: zope.webdav/trunk/src/zope/webdav/ftests/ftesting.zcml
===================================================================
--- zope.webdav/trunk/src/zope/webdav/ftests/ftesting.zcml 2007-02-13 19:25:25 UTC (rev 72543)
+++ zope.webdav/trunk/src/zope/webdav/ftests/ftesting.zcml 2007-02-13 19:30:17 UTC (rev 72544)
@@ -52,8 +52,6 @@
<include package="zope.app.folder" />
<include package="zope.app.file" />
- <include package="zope.annotation" />
- <include package="zope.dublincore" />
<!--
Some random bits.
Modified: zope.webdav/trunk/src/zope/webdav/ftests/test_proppatch.py
===================================================================
--- zope.webdav/trunk/src/zope/webdav/ftests/test_proppatch.py 2007-02-13 19:25:25 UTC (rev 72543)
+++ zope.webdav/trunk/src/zope/webdav/ftests/test_proppatch.py 2007-02-13 19:30:17 UTC (rev 72544)
@@ -56,7 +56,6 @@
def test_setdisplayname_unauthorized(self):
file = self.addResource("/r", "some content", title = u"Test Resource")
-
body = """<?xml version="1.0" encoding="utf-8" ?>
<D:propertyupdate xmlns:D="DAV:" xmlns="DAV:">
<D:set><D:prop>
@@ -72,6 +71,9 @@
# we need to be logged in to set the DAV:displayname property.
self.assertEqual(response.getStatus(), 401)
+ self.assertEqual(
+ response.getHeader("WWW-Authenticate", literal = True),
+ 'basic realm="Zope"')
def test_setdisplayname(self):
set_properties = "<D:displayname>Test File</D:displayname>"
Modified: zope.webdav/trunk/src/zope/webdav/mkcol.py
===================================================================
--- zope.webdav/trunk/src/zope/webdav/mkcol.py 2007-02-13 19:25:25 UTC (rev 72543)
+++ zope.webdav/trunk/src/zope/webdav/mkcol.py 2007-02-13 19:30:17 UTC (rev 72544)
@@ -59,11 +59,13 @@
>>> events
[]
+ >>> request = TestRequest(environ = {'CONTENT_LENGTH': 0})
+
If no adapter implementing IWriteDirectory is registered for then we
will never be able to create a new collection and hence this operation
is forbidden.
- >>> MKCOL(context, TestRequest()).MKCOL()
+ >>> MKCOL(context, request).MKCOL()
Traceback (most recent call last):
...
ForbiddenError
@@ -89,7 +91,7 @@
>>> events = []
- >>> MKCOL(context, TestRequest()).MKCOL()
+ >>> MKCOL(context, request).MKCOL()
Traceback (most recent call last):
...
ForbiddenError
@@ -111,8 +113,6 @@
>>> component.getGlobalSiteManager().registerAdapter(DirectoryFactory)
>>> events = []
- >>> request = TestRequest()
-
The next call to the mkcol implementation will succeed and create
a new folder with the name 'newdir'.
@@ -156,9 +156,7 @@
self.request = request
def MKCOL(self):
- request = self.request
- data = request.bodyStream.read()
- if len(data):
+ if self.request.getHeader("content-length") > 0:
# We don't (yet) support a request body on MKCOL.
raise zope.webdav.interfaces.UnsupportedMediaType(
self.context,
@@ -177,5 +175,5 @@
zope.event.notify(ObjectCreatedEvent(newdir))
dir[name] = newdir
- request.response.setStatus(201)
+ self.request.response.setStatus(201)
return ""
Modified: zope.webdav/trunk/src/zope/webdav/propfind.py
===================================================================
--- zope.webdav/trunk/src/zope/webdav/propfind.py 2007-02-13 19:25:25 UTC (rev 72543)
+++ zope.webdav/trunk/src/zope/webdav/propfind.py 2007-02-13 19:30:17 UTC (rev 72544)
@@ -54,9 +54,6 @@
class PROPFIND(object):
"""
PROPFIND handler for all objects.
-
- The PROPFIND method handles parsing of the XML body and then calls the
-
"""
interface.implements(zope.webdav.interfaces.IWebDAVMethod)
component.adapts(interface.Interface, zope.webdav.interfaces.IWebDAVRequest)
@@ -70,7 +67,7 @@
return self.request.getHeader("depth", "infinity")
def PROPFIND(self):
- if len(self.request.bodyStream.getCacheStream().read()) > 0 and \
+ if self.request.getHeader("content-length") > 0 and \
self.request.content_type not in ("text/xml", "application/xml"):
raise zope.webdav.interfaces.BadRequest(
self.request,
@@ -150,7 +147,7 @@
error_view = component.queryMultiAdapter(
(exc_info[1], request), zope.webdav.interfaces.IDAVErrorWidget)
if error_view is None:
- ## An unexpected error occured here. This errr should be
+ ## An unexpected error occured here. This error should be
## fixed. In order to easily debug the problem we will
## log the error with the ErrorReportingUtility
errUtility = component.getUtility(IErrorReportingUtility)
@@ -215,15 +212,14 @@
davprop, adapter, req)
response.addProperty(200, davwidget.render())
except Unauthorized:
+ # Users don't have the permission to view this property and
+ # if they didn't explicitly ask for the named property
+ # we will silently ignore this property.
if isIncluded:
self.handleException(
"{%s}%s" %(davprop.namespace, davprop.__name__),
sys.exc_info(), req,
response)
- # Users don't have the permission to view this property and
- # since they didn't explicitly ask for the named property
- # we will silently ignore this property.
- pass
except Exception:
self.handleException(
"{%s}%s" %(davprop.namespace, davprop.__name__),
More information about the Checkins
mailing list