[CalendarServer-changes] [5632] CalendarServer/trunk/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Thu May 20 10:59:29 PDT 2010
Revision: 5632
http://trac.macosforge.org/projects/calendarserver/changeset/5632
Author: cdaboo at apple.com
Date: 2010-05-20 10:59:27 -0700 (Thu, 20 May 2010)
Log Message:
-----------
Fix directory gateway.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/directory/opendirectorybacker.py
CalendarServer/trunk/twistedcaldav/query/addressbookqueryfilter.py
CalendarServer/trunk/twistedcaldav/simpleresource.py
CalendarServer/trunk/twistedcaldav/static.py
Modified: CalendarServer/trunk/twistedcaldav/directory/opendirectorybacker.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/opendirectorybacker.py 2010-05-20 17:57:38 UTC (rev 5631)
+++ CalendarServer/trunk/twistedcaldav/directory/opendirectorybacker.py 2010-05-20 17:59:27 UTC (rev 5632)
@@ -814,7 +814,7 @@
if constant:
# do the match right now! Return either all or none.
- return( textMatchElement.match([constant,]), [], [] )
+ return( textMatchElement.test([constant,]), [], [] )
else:
matchStrings = getMatchStrings(propFilter, textMatchElement.text)
Modified: CalendarServer/trunk/twistedcaldav/query/addressbookqueryfilter.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/query/addressbookqueryfilter.py 2010-05-20 17:57:38 UTC (rev 5631)
+++ CalendarServer/trunk/twistedcaldav/query/addressbookqueryfilter.py 2010-05-20 17:59:27 UTC (rev 5632)
@@ -69,7 +69,7 @@
if len(self.children) > 0:
allof = self.filter_test == "allof"
for propfilter in self.children:
- if allof != propfilter._match(vcard):
+ if allof != propfilter.test(vcard):
return not allof
return allof
else:
@@ -153,7 +153,7 @@
if len(self.filters) > 0:
allof = self.propfilter_test == "allof"
for filter in self.filters:
- if allof != filter._match(item):
+ if allof != filter.test(item):
return not allof
return allof
else:
@@ -164,7 +164,7 @@
Limits a search to specific properties.
"""
- def _match(self, vcard):
+ def test(self, vcard):
# At least one property must match (or is-not-defined is set)
for property in vcard.properties():
if property.name() == self.filter_name and self.match(property): break
@@ -188,7 +188,7 @@
Limits a search to specific parameters.
"""
- def _match(self, property):
+ def test(self, property):
# At least one parameter must match (or is-not-defined is set)
result = not self.defined
@@ -246,7 +246,7 @@
else:
self.match_type = "contains"
- def _match(self, item):
+ def test(self, item):
"""
Match the text for the item.
If the item is a property, then match the property value,
Modified: CalendarServer/trunk/twistedcaldav/simpleresource.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/simpleresource.py 2010-05-20 17:57:38 UTC (rev 5631)
+++ CalendarServer/trunk/twistedcaldav/simpleresource.py 2010-05-20 17:59:27 UTC (rev 5632)
@@ -20,6 +20,7 @@
from twistedcaldav.directory.util import NotFilePath
from twistedcaldav.extensions import DAVFile
from twistedcaldav.resource import CalDAVResource
+from twistedcaldav.static import CalDAVFile
"""
Implements a simple non-file resource.
@@ -27,6 +28,7 @@
__all__ = [
"SimpleResource",
+ "SimpleCalDAVResource",
]
class SimpleResource (
@@ -56,7 +58,7 @@
Make sure it is a collection.
"""
CalDAVResource.__init__(self, principalCollections=principalCollections)
- DAVFile.__init__(self, NotFilePath(isdir=isdir), principalCollections=principalCollections)
+ DAVFile.__init__(self, NotFilePath(isfile=not isdir,isdir=isdir), principalCollections=principalCollections)
self.defaultACL = defaultACL
def locateChild(self, req, segments):
@@ -81,3 +83,55 @@
def accessControlList(self, request, inheritance=True, expanding=False, inherited_aces=None):
return succeed(self.defaultACL)
+
+class SimpleCalDAVResource (
+ CalDAVFile,
+):
+
+ allReadACL = davxml.ACL(
+ # Read access for all users.
+ davxml.ACE(
+ davxml.Principal(davxml.All()),
+ davxml.Grant(davxml.Privilege(davxml.Read())),
+ davxml.Protected(),
+ ),
+ )
+ authReadACL = davxml.ACL(
+ # Read access for authenticated users.
+ davxml.ACE(
+ davxml.Principal(davxml.Authenticated()),
+ davxml.Grant(davxml.Privilege(davxml.Read())),
+ davxml.Protected(),
+ ),
+ )
+
+ def __init__(self, principalCollections, isdir=False, defaultACL=authReadACL):
+ """
+ Make sure it is a collection.
+ """
+ CalDAVResource.__init__(self, principalCollections=principalCollections)
+ DAVFile.__init__(self, NotFilePath(isfile=not isdir,isdir=isdir), principalCollections=principalCollections)
+ self.defaultACL = defaultACL
+
+ def locateChild(self, req, segments):
+ child = self.getChild(segments[0])
+ if child is not None:
+ return (child, segments[1:])
+ return (None, ())
+
+ def getChild(self, name):
+ if name == "":
+ return self
+ else:
+ return self.putChildren.get(name, None)
+
+ def deadProperties(self):
+ if not hasattr(self, "_dead_properties"):
+ self._dead_properties = NonePropertyStore(self)
+ return self._dead_properties
+
+ def etag(self):
+ return None
+
+ def accessControlList(self, request, inheritance=True, expanding=False, inherited_aces=None):
+ return succeed(self.defaultACL)
Modified: CalendarServer/trunk/twistedcaldav/static.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/static.py 2010-05-20 17:57:38 UTC (rev 5631)
+++ CalendarServer/trunk/twistedcaldav/static.py 2010-05-20 17:59:27 UTC (rev 5632)
@@ -1672,11 +1672,15 @@
if name is "":
return self
else:
- return CalDAVFile(
- self.fp,
- principalCollections=self.principalCollections()
- ).getChild(name)
+ from twistedcaldav.simpleresource import SimpleCalDAVResource
+ return SimpleCalDAVResource(principalCollections=self.principalCollections())
+ def createSimilarFile(self, path):
+ if self.comparePath(path):
+ return self
+ else:
+ from twistedcaldav.simpleresource import SimpleCalDAVResource
+ return SimpleCalDAVResource(principalCollections=self.principalCollections())
class GlobalAddressBookFile (ReadOnlyResourceMixIn, GlobalAddressBookResource, CalDAVFile):
"""
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100520/2f92b0d4/attachment-0001.html>
More information about the calendarserver-changes
mailing list