[CalendarServer-changes] [439] CalendarServer/branches/users/wsanchez/provisioning/lib-patches/ Twisted/twisted.web2.dav.static.patch

source_changes at macosforge.org source_changes at macosforge.org
Mon Nov 13 14:02:24 PST 2006


Revision: 439
          http://trac.macosforge.org/projects/calendarserver/changeset/439
Author:   wsanchez at apple.com
Date:     2006-11-13 14:02:24 -0800 (Mon, 13 Nov 2006)

Log Message:
-----------
Remove render() from DAVFile.

You don't need read access to a resource in order to find out that the
resource exists; read access to the collection that contains it should
be enough.

It doesn't help that doing ACL eval on all of the children seriously
slows down render().

Modified Paths:
--------------
    CalendarServer/branches/users/wsanchez/provisioning/lib-patches/Twisted/twisted.web2.dav.static.patch

Modified: CalendarServer/branches/users/wsanchez/provisioning/lib-patches/Twisted/twisted.web2.dav.static.patch
===================================================================
--- CalendarServer/branches/users/wsanchez/provisioning/lib-patches/Twisted/twisted.web2.dav.static.patch	2006-11-13 20:51:54 UTC (rev 438)
+++ CalendarServer/branches/users/wsanchez/provisioning/lib-patches/Twisted/twisted.web2.dav.static.patch	2006-11-13 22:02:24 UTC (rev 439)
@@ -8,10 +8,10 @@
  
 -import os
 -
-+from twisted.internet.defer import succeed, deferredGenerator, waitForDeferred
- from twisted.python import log
--from twisted.internet.defer import succeed, deferredGenerator, waitForDeferred
+-from twisted.python import log
+ from twisted.internet.defer import succeed, deferredGenerator, waitForDeferred
 -from twisted.web2.static import File
++from twisted.python import log
 +from twisted.web2 import http_headers
  from twisted.web2 import responsecode, dirlist
 -from twisted.web2.http import RedirectResponse
@@ -96,14 +96,21 @@
      # Workarounds for issues with File
      ##
  
-@@ -142,53 +191,50 @@
-         directory contents that they have read permissions for.
-         """
-         if not self.fp.exists():
+@@ -134,61 +183,6 @@
+     def createSimilarFile(self, path):
+         return self.__class__(path, defaultType=self.defaultType, indexNames=self.indexNames[:])
+ 
+-    def render(self, request):
+-        """
+-        This is a direct copy of web2.static.render with the
+-        listChildren behavior replaced with findChildren to ensure
+-        that the current authenticated principal can only list
+-        directory contents that they have read permissions for.
+-        """
+-        if not self.fp.exists():
 -            yield responsecode.NOT_FOUND
 -            return
-+            return responsecode.NOT_FOUND
- 
+-
 -        if self.fp.isdir():
 -            if request.uri[-1] != "/":
 -                # Redirect to include trailing '/' in URI
@@ -119,32 +126,19 @@
 -                    filtered_aces = waitForDeferred(self.inheritedACEsforChildren(request))
 -                    yield filtered_aces
 -                    filtered_aces = filtered_aces.getResult()
-+        if not self.fp.isdir():
-+            # Do regular resource behavior from superclass
-+            return super(DAVFile, self).render(request)
- 
+-
 -                    children = []
-+        #
-+        # Do custom rendering of directory so that we can enforce ACLs.
-+        #
- 
+-
 -                    def found(request, uri):
 -                        children.append(uri.split("/")[-1].rstrip("/"))
-+        if request.uri[-1] != "/":
-+            # Redirect to include trailing '/' in URI
-+            return RedirectResponse(request.unparseURL(path=request.path+'/'))
- 
+-
 -                    x = waitForDeferred(
 -                        self.findChildren("1", request, found, (davxml.Read(),),
 -                                          inherited_aces=filtered_aces)
 -                    )
 -                    yield x
 -                    x = x.getResult()
-+        # Render from the index file, if we have one
-+        index_fp = self.fp.childSearchPreauth(*self.indexNames)
-+        if index_fp:
-+            return self.createSimilarFile(index_fp.path).render(request)
- 
+-
 -                    # Render from a DirectoryLister
 -                    standin = dirlist.DirectoryLister(
 -                        self.fp.path,
@@ -155,35 +149,12 @@
 -                    )
 -                yield standin.render(request)
 -                return
-+        # Render from a DirectoryLister
-+        def findChildren(filtered_aces):
-+            children = []
- 
+-
 -        # Do regular resource behavior from superclass
 -        yield super(DAVFile, self).render(request)
 -    
 -    render = deferredGenerator(render)
-+            def found(request, uri):
-+                children.append(uri.rstrip("/").split("/")[-1])
- 
-+            d = self.findChildren("1", request, found,
-+                                  (davxml.Read(),), inherited_aces=filtered_aces)
-+            d.addCallback(render, children)
-+            return d
-+
-+        def render(_, children):
-+            return dirlist.DirectoryLister(
-+                self.fp.path,
-+                children,
-+                self.contentTypes,
-+                self.contentEncodings,
-+                self.defaultType
-+            ).render(request)
-+
-+        d = self.inheritedACEsforChildren(request)
-+        d.addCallback(findChildren)
-+        return d
-+
+-
  #
  # Attach method handlers to DAVFile
  #

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20061113/9844482d/attachment.html


More information about the calendarserver-changes mailing list