[CalendarServer-changes] [4549] CalendarServer/branches/users/wsanchez/deployment
source_changes at macosforge.org
source_changes at macosforge.org
Tue Sep 22 12:58:45 PDT 2009
Revision: 4549
http://trac.macosforge.org/projects/calendarserver/changeset/4549
Author: cdaboo at apple.com
Date: 2009-09-22 12:58:42 -0700 (Tue, 22 Sep 2009)
Log Message:
-----------
Reduce number of file systems stats.
Modified Paths:
--------------
CalendarServer/branches/users/wsanchez/deployment/lib-patches/Twisted/twisted.web2.dav.xattrprops.patch
CalendarServer/branches/users/wsanchez/deployment/lib-patches/Twisted/twisted.web2.server.patch
CalendarServer/branches/users/wsanchez/deployment/lib-patches/Twisted/twisted.web2.static.patch
CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/principal.py
CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/resource.py
CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/util.py
CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/method/put.py
CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/static.py
Modified: CalendarServer/branches/users/wsanchez/deployment/lib-patches/Twisted/twisted.web2.dav.xattrprops.patch
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment/lib-patches/Twisted/twisted.web2.dav.xattrprops.patch 2009-09-16 21:19:52 UTC (rev 4548)
+++ CalendarServer/branches/users/wsanchez/deployment/lib-patches/Twisted/twisted.web2.dav.xattrprops.patch 2009-09-22 19:58:42 UTC (rev 4549)
@@ -46,7 +46,7 @@
return r
def _decode(clazz, name):
-@@ -97,19 +98,83 @@
+@@ -97,22 +98,86 @@
def get(self, qname):
try:
@@ -133,7 +133,11 @@
+ break
# Update the resource because we've modified it
- self.resource.fp.restat()
+- self.resource.fp.restat()
++ self.resource.fp.changed()
+
+ def delete(self, qname):
+ try:
@@ -121,15 +186,31 @@
# RFC 2518 Section 12.13.1 says that removal of
# non-existing property is not an error.
Modified: CalendarServer/branches/users/wsanchez/deployment/lib-patches/Twisted/twisted.web2.server.patch
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment/lib-patches/Twisted/twisted.web2.server.patch 2009-09-16 21:19:52 UTC (rev 4548)
+++ CalendarServer/branches/users/wsanchez/deployment/lib-patches/Twisted/twisted.web2.server.patch 2009-09-22 19:58:42 UTC (rev 4549)
@@ -72,15 +72,26 @@
return res
#else:
# raise ValueError("locateChild must not return StopTraversal with a resource other than self.")
-@@ -337,7 +356,6 @@
+@@ -335,9 +354,17 @@
+ # We found a Resource... update the request.prepath and postpath
+ for x in xrange(len(path) - len(newpath)):
self.prepath.append(self.postpath.pop(0))
++ url = quote("/" + "/".join(self.prepath) + ("/" if self.prepath and self.prepath[-1] else ""))
++ self._rememberResource(newres, url)
++ else:
++ try:
++ previousURL = self.urlForResource(res)
++ url = quote(previousURL + path[0] + ("/" if path[0] and len(path) > 1 else ""))
++ self._rememberResource(newres, url)
++ except NoURLForResourceError:
++ pass
child = self._getChild(None, newres, newpath, updatepaths=updatepaths)
- self._rememberResource(child, url)
return child
-@@ -347,6 +365,7 @@
+@@ -347,6 +374,7 @@
"""
Remember the URL of a visited resource.
"""
@@ -88,7 +99,7 @@
self._urlsByResource[resource] = url
return resource
-@@ -386,7 +405,8 @@
+@@ -386,7 +414,8 @@
The contained response will have a status code of
L{responsecode.BAD_REQUEST}.
"""
@@ -98,7 +109,7 @@
#
# Parse the URL
-@@ -407,9 +427,13 @@
+@@ -407,17 +436,37 @@
"URL is not on this site (%s://%s/): %s" % (scheme, self.headers.getHeader("host"), url)
))
@@ -112,14 +123,30 @@
assert segments[0] == "", "URL path didn't begin with '/': %s" % (path,)
- segments = map(unquote, segments[1:])
++ # Walk the segments up to see if we can find a cached resource to start from
++ preSegments = segments[:-1]
++ postSegments = segments[-1:]
++ cachedParent = None
++ while(len(preSegments)):
++ parentPath = "/".join(preSegments) + "/"
++ cachedParent = self._resourcesByURL.get(parentPath, None)
++ if cachedParent is not None:
++ break
++ else:
++ postSegments.insert(0, preSegments.pop())
++
++ if cachedParent is None:
++ cachedParent = self.site.resource
++ postSegments = segments[1:]
++
def notFound(f):
f.trap(http.HTTPError)
-@@ -417,7 +441,7 @@
+ if f.value.response.code != responsecode.NOT_FOUND:
return f
return None
- d = defer.maybeDeferred(self._getChild, None, self.site.resource, segments, updatepaths=False)
-+ d = defer.maybeDeferred(self._getChild, None, self.site.resource, segments[1:], updatepaths=False)
++ d = defer.maybeDeferred(self._getChild, None, cachedParent, postSegments, updatepaths=False)
d.addCallback(self._rememberResource, path)
d.addErrback(notFound)
return d
Modified: CalendarServer/branches/users/wsanchez/deployment/lib-patches/Twisted/twisted.web2.static.patch
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment/lib-patches/Twisted/twisted.web2.static.patch 2009-09-16 21:19:52 UTC (rev 4548)
+++ CalendarServer/branches/users/wsanchez/deployment/lib-patches/Twisted/twisted.web2.static.patch 2009-09-22 19:58:42 UTC (rev 4549)
@@ -14,7 +14,39 @@
# Remove the dots from the path to split
self.defaultType = defaultType
self.ignoredExts = list(ignoredExts)
-@@ -383,7 +386,7 @@
+@@ -213,6 +216,13 @@
+ if indexNames is not None:
+ self.indexNames = indexNames
+
++ def comparePath(self, path):
++
++ if isinstance(path, filepath.FilePath):
++ return path.path == self.fp.path
++ else:
++ return path == self.fp.path
++
+ def exists(self):
+ return self.fp.exists()
+
+@@ -318,7 +328,7 @@
+
+ child_fp = self.fp.child(name)
+ if child_fp.exists():
+- return self.createSimilarFile(child_fp.path)
++ return self.createSimilarFile(child_fp)
+ else:
+ return None
+
+@@ -374,7 +384,7 @@
+ return self.createSimilarFile(fpath.path), segments[1:]
+
+ def renderHTTP(self, req):
+- self.fp.restat(False)
++ self.fp.changed()
+ return super(File, self).renderHTTP(req)
+
+ def render(self, req):
+@@ -383,7 +393,7 @@
return responsecode.NOT_FOUND
if self.fp.isdir():
Modified: CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/principal.py
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/principal.py 2009-09-16 21:19:52 UTC (rev 4548)
+++ CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/principal.py 2009-09-22 19:58:42 UTC (rev 4549)
@@ -720,11 +720,8 @@
return succeed(inbox)
def calendarHomeURLs(self):
- home = self._calendarHome()
- if home is None:
- return ()
- else:
- return (home.url(),)
+ homeURL = self._homeChildURL(None)
+ return (homeURL,) if homeURL else ()
def scheduleInboxURL(self):
return self._homeChildURL("inbox/")
@@ -739,11 +736,19 @@
return None
def _homeChildURL(self, name):
- home = self._calendarHome()
- if home is None:
+ if not hasattr(self, "calendarHomeURL"):
+ home = self._calendarHome()
+ if home is None:
+ self.calendarHomeURL = None
+ return None
+ else:
+ self.calendarHomeURL = home.url()
+
+ url = self.calendarHomeURL
+ if url is None:
return None
else:
- return joinURL(home.url(), name)
+ return joinURL(url, name) if name else url
def _calendarHome(self):
# FIXME: self.record.service.calendarHomesCollection smells like a hack
Modified: CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/resource.py
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/resource.py 2009-09-16 21:19:52 UTC (rev 4548)
+++ CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/resource.py 2009-09-22 19:58:42 UTC (rev 4549)
@@ -20,7 +20,7 @@
__all__ = ["AutoProvisioningResourceMixIn"]
-from twisted.internet.defer import maybeDeferred
+from twisted.internet.defer import maybeDeferred, inlineCallbacks, returnValue
class AutoProvisioningResourceMixIn (object):
"""
@@ -50,16 +50,19 @@
"""
return None
+ @inlineCallbacks
def locateChild(self, request, segments):
"""
This implementation calls L{provision}, then super's L{locateChild}, thereby
ensuring that looked-up resources are provisioned.
"""
- d = maybeDeferred(self.provision)
+ yield maybeDeferred(self.provision)
name = segments[0]
if name != "":
- d.addCallback(lambda _: self.provisionChild(name))
-
- d.addCallback(lambda _: super(AutoProvisioningResourceMixIn, self).locateChild(request, segments))
- return d
+ child = self.provisionChild(name)
+ if child:
+ returnValue((child, segments[1:],))
+
+ result = (yield super(AutoProvisioningResourceMixIn, self).locateChild(request, segments))
+ returnValue(result)
Modified: CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/util.py
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/util.py 2009-09-16 21:19:52 UTC (rev 4548)
+++ CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/util.py 2009-09-22 19:58:42 UTC (rev 4549)
@@ -129,6 +129,9 @@
def dirname(self):
return ""
+ def changed(self):
+ pass
+
def restat(self, reraise=True):
pass
Modified: CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/method/put.py
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/method/put.py 2009-09-16 21:19:52 UTC (rev 4548)
+++ CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/method/put.py 2009-09-22 19:58:42 UTC (rev 4549)
@@ -41,7 +41,6 @@
parent = parent.getResult()
if isPseudoCalendarCollectionResource(parent):
- self.fp.restat(False)
# Content-type check
content_type = request.headers.getHeader("content-type")
Modified: CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/static.py
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/static.py 2009-09-16 21:19:52 UTC (rev 4548)
+++ CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/static.py 2009-09-22 19:58:42 UTC (rev 4549)
@@ -333,7 +333,7 @@
return self._propertyCollection
def createSimilarFile(self, path):
- if path == self.fp.path:
+ if self.comparePath(path):
return self
similar = super(CalDAVFile, self).createSimilarFile(path)
@@ -509,6 +509,13 @@
else:
self._provisioned_file = True
+ # If the file already exists we can just exit here - there is no need to go further
+ if self.fp.exists():
+ return False
+
+ # At this point the original FilePath did not indicate an existing file, but we should
+ # recheck it to see if some other request sneaked in and already created/provisioned it
+
fp = self.fp
fp.restat(False)
@@ -533,10 +540,10 @@
# Check our status again, and re-raise if we're not a collection.
if not self.isCollection():
raise
- fp.restat(False)
+ fp.changed()
else:
fp.open("w").close()
- fp.restat(False)
+ fp.changed()
return True
@@ -623,7 +630,7 @@
responsecode.INTERNAL_SERVER_ERROR,
"Unable to move calendar home."
))
- child.fp.restat(False)
+ child.fp.changed()
break
else:
#
@@ -693,7 +700,7 @@
return self.createSimilarFile(self.fp.child(name).path)
def createSimilarFile(self, path):
- if path == self.fp.path:
+ if self.comparePath(path):
return self
else:
similar = CalDAVFile(path, principalCollections=self.principalCollections())
@@ -770,7 +777,7 @@
return True
def createSimilarFile(self, path):
- if path == self.fp.path:
+ if self.comparePath(path):
return self
else:
return CalDAVFile(path, principalCollections=self.principalCollections())
@@ -850,7 +857,7 @@
self.parent = parent
def createSimilarFile(self, path):
- if path == self.fp.path:
+ if self.comparePath(path):
return self
else:
return DropBoxCollectionFile(path, self)
@@ -864,7 +871,7 @@
CalDAVFile.__init__(self, path, principalCollections=parent.principalCollections())
def createSimilarFile(self, path):
- if path == self.fp.path:
+ if self.comparePath(path):
return self
else:
return DropBoxChildFile(path, self)
@@ -879,7 +886,7 @@
assert self.fp.isfile() or not self.fp.exists()
def createSimilarFile(self, path):
- if path == self.fp.path:
+ if self.comparePath(path):
return self
else:
return responsecode.NOT_FOUND
@@ -892,7 +899,7 @@
assert self.fp.isfile() or not self.fp.exists()
def createSimilarFile(self, path):
- if path == self.fp.path:
+ if self.comparePath(path):
return self
else:
return responsecode.NOT_FOUND
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20090922/4a3f9edc/attachment-0001.html>
More information about the calendarserver-changes
mailing list