Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Also be persnikety about case variants in CalendarHomeProvisioningFile.

  • Loading branch information
wsanchez committed Oct 5, 2006
1 parent 38b225d commit 2293b8acd21b5265bd919af36aa4065aa1210272
Showing with 26 additions and 15 deletions.
  1. +26 −15 twistedcaldav/static.py
@@ -599,18 +599,8 @@ def __init__(self, path):
if not child_fp.exists(): child_fp.makedirs()
self.putChild(name, clazz(child_fp.path))

def locateChild(self, req, segments):
"""
This implementation tries fails to find children we don't already know
about.
"""
# If getChild() finds a child resource, return it
child = self.getChild(segments[0])
if child is not None:
return (child, segments[1:])

# Otherwise, there is no child
return (None, ())
def locateChild(self, request, segments):
return locateExistingChild(self, request, segments)

def getChild(self, name):
# This avoids finding case variants of put children on case-insensitive filesystems.
@@ -661,19 +651,23 @@ def hasChild(self, name):
"""
return name in self.listChildren()

def locateChild(self, request, segments):
return locateExistingChild(self, request, segments)

def getChild(self, name):
if name == "": return self

# Avoid case variants when allocating resources
if not self.hasChild(name):
return None

child_fp = self.fp.child(name)
if child_fp.exists():
assert child_fp.isdir()
else:
assert self.exists()
assert self.isCollection()

if not self.hasChild(name):
return None

child_fp.makedirs()

return self.calendarHomeClass(child_fp.path)
@@ -945,6 +939,23 @@ def http_PUT (self, request): return responsecode.FORBIDDEN
def http_MKCOL (self, request): return responsecode.FORBIDDEN
def http_MKCALENDAR (self, request): return responsecode.FORBIDDEN

##
# Utilities
##

def locateExistingChild(resource, request, segments):
"""
This C{locateChild()} implementation fails to find children if C{getChild()}
doesn't return one.
"""
# If getChild() finds a child resource, return it
child = resource.getChild(segments[0])
if child is not None:
return (child, segments[1:])

# Otherwise, there is no child
return (None, ())

##
# Attach methods
##

0 comments on commit 2293b8a

Please sign in to comment.
You can’t perform that action at this time.