[CalendarServer-changes] [5704] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Tue Jun 8 13:41:17 PDT 2010
Revision: 5704
http://trac.macosforge.org/projects/calendarserver/changeset/5704
Author: cdaboo at apple.com
Date: 2010-06-08 13:41:14 -0700 (Tue, 08 Jun 2010)
Log Message:
-----------
Cached internet calendar subscription behavior merged from branch.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/method/__init__.py
CalendarServer/trunk/twistedcaldav/static.py
Added Paths:
-----------
CalendarServer/trunk/twistedcaldav/method/acl.py
Property Changed:
----------------
CalendarServer/trunk/
Property changes on: CalendarServer/trunk
___________________________________________________________________
Modified: svn:mergeinfo
- /CalendarServer/branches/config-separation:4379-4443
/CalendarServer/branches/egg-info-351:4589-4625
/CalendarServer/branches/users/cdaboo/directory-cache-on-demand-3627:3628-3644
/CalendarServer/branches/users/cdaboo/more-sharing-5591:5592-5601
/CalendarServer/branches/users/cdaboo/partition-4464:4465-4957
/CalendarServer/branches/users/cdaboo/relative-config-paths-5070:5071-5105
/CalendarServer/branches/users/cdaboo/shared-calendars-5187:5188-5440
/CalendarServer/branches/users/glyph/contacts-server-merge:4971-5080
/CalendarServer/branches/users/glyph/sendfdport:5388-5424
/CalendarServer/branches/users/glyph/use-system-twisted:5084-5149
/CalendarServer/branches/users/sagen/locations-resources:5032-5051
/CalendarServer/branches/users/sagen/locations-resources-2:5052-5061
/CalendarServer/branches/users/sagen/resource-delegates-4038:4040-4067
/CalendarServer/branches/users/sagen/resource-delegates-4066:4068-4075
/CalendarServer/branches/users/sagen/resources-2:5084-5093
+ /CalendarServer/branches/config-separation:4379-4443
/CalendarServer/branches/egg-info-351:4589-4625
/CalendarServer/branches/users/cdaboo/cached-subscription-calendars-5692:5693-5702
/CalendarServer/branches/users/cdaboo/directory-cache-on-demand-3627:3628-3644
/CalendarServer/branches/users/cdaboo/more-sharing-5591:5592-5601
/CalendarServer/branches/users/cdaboo/partition-4464:4465-4957
/CalendarServer/branches/users/cdaboo/relative-config-paths-5070:5071-5105
/CalendarServer/branches/users/cdaboo/shared-calendars-5187:5188-5440
/CalendarServer/branches/users/glyph/contacts-server-merge:4971-5080
/CalendarServer/branches/users/glyph/sendfdport:5388-5424
/CalendarServer/branches/users/glyph/use-system-twisted:5084-5149
/CalendarServer/branches/users/sagen/locations-resources:5032-5051
/CalendarServer/branches/users/sagen/locations-resources-2:5052-5061
/CalendarServer/branches/users/sagen/resource-delegates-4038:4040-4067
/CalendarServer/branches/users/sagen/resource-delegates-4066:4068-4075
/CalendarServer/branches/users/sagen/resources-2:5084-5093
Modified: CalendarServer/trunk/twistedcaldav/method/__init__.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/method/__init__.py 2010-06-08 20:40:27 UTC (rev 5703)
+++ CalendarServer/trunk/twistedcaldav/method/__init__.py 2010-06-08 20:41:14 UTC (rev 5704)
@@ -22,6 +22,7 @@
"""
__all__ = [
+ "acl",
"copymove",
"delete",
"get",
Copied: CalendarServer/trunk/twistedcaldav/method/acl.py (from rev 5702, CalendarServer/branches/users/cdaboo/cached-subscription-calendars-5692/twistedcaldav/method/acl.py)
===================================================================
--- CalendarServer/trunk/twistedcaldav/method/acl.py (rev 0)
+++ CalendarServer/trunk/twistedcaldav/method/acl.py 2010-06-08 20:41:14 UTC (rev 5704)
@@ -0,0 +1,55 @@
+##
+# Copyright (c) 2006-2009 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+"""
+CalDAV ACL method.
+"""
+
+__all__ = ["http_ACL"]
+
+
+from twext.python.log import Logger
+from twext.web2 import responsecode
+from twext.web2.dav.util import parentForURL
+from twext.web2.http import HTTPError
+
+from twisted.internet.defer import inlineCallbacks, returnValue
+
+from twistedcaldav.resource import isAddressBookCollectionResource,\
+ isPseudoCalendarCollectionResource
+from twistedcaldav.static import AddressBookHomeFile, CalendarHomeFile
+
+log = Logger()
+
+ at inlineCallbacks
+def http_ACL(self, request):
+ #
+ # Override base ACL request handling to ensure that the calendar/address book
+ # homes cannot have ACL's set, and calendar/address object resources too.
+ #
+
+ if self.fp.exists():
+ if isinstance(self, CalendarHomeFile) or isinstance(self, AddressBookHomeFile):
+ raise HTTPError(responsecode.NOT_ALLOWED)
+
+ parentURL = parentForURL(request.uri)
+ parent = (yield request.locateResource(parentURL))
+ if isPseudoCalendarCollectionResource(parent) or isAddressBookCollectionResource(parent):
+ raise HTTPError(responsecode.NOT_ALLOWED)
+
+ # Do normal ACL behavior
+ response = (yield super(CalDAVFile, self).http_ACL(request))
+ returnValue(response)
Modified: CalendarServer/trunk/twistedcaldav/static.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/static.py 2010-06-08 20:40:27 UTC (rev 5703)
+++ CalendarServer/trunk/twistedcaldav/static.py 2010-06-08 20:41:14 UTC (rev 5704)
@@ -284,13 +284,46 @@
@inlineCallbacks
def iCalendarRolledup(self, request):
if self.isPseudoCalendarCollection():
+
+ # Determine the cache key
+ isvirt = (yield self.isVirtualShare(request))
+ if isvirt:
+ principal = (yield self.resourceOwnerPrincipal(request))
+ if principal:
+ cacheKey = principal.principalUID()
+ else:
+ cacheKey = "unknown"
+ else:
+ isowner = (yield self.isOwner(request, adminprincipals=True, readprincipals=True))
+ cacheKey = "owner" if isowner else "notowner"
+
+ # Now check for a cached .ics
+ rolled = self.fp.child(".subscriptions")
+ if not rolled.exists():
+ try:
+ rolled.makedirs()
+ except IOError, e:
+ log.err("Unable to create internet calendar subscription cache directory: %s because of: %s" % (rolled.path, e,))
+ raise HTTPError(ErrorResponse(responsecode.INTERNAL_SERVER_ERROR))
+ cached = rolled.child(cacheKey)
+ if cached.exists():
+ try:
+ cachedData = cached.open().read()
+ except IOError, e:
+ log.err("Unable to open or read internet calendar subscription cache file: %s because of: %s" % (cached.path, e,))
+ else:
+ # Check the cache token
+ token, data = cachedData.split("\r\n", 1)
+ if token == self.getSyncToken():
+ returnValue(data)
+
# Generate a monolithic calendar
calendar = iComponent("VCALENDAR")
calendar.addProperty(iProperty("VERSION", "2.0"))
# Do some optimisation of access control calculation by determining any inherited ACLs outside of
# the child resource loop and supply those to the checkPrivileges on each child.
- filteredaces = yield self.inheritedACEsforChildren(request)
+ filteredaces = (yield self.inheritedACEsforChildren(request))
tzids = set()
isowner = (yield self.isOwner(request, adminprincipals=True, readprincipals=True))
@@ -329,6 +362,14 @@
calendar.addComponent(component)
+ # Cache the data
+ data = str(calendar)
+ data = self.getSyncToken() + "\r\n" + data
+ try:
+ cached.open(mode='w').write(data)
+ except IOError, e:
+ log.err("Unable to open or write internet calendar subscription cache file: %s because of: %s" % (cached.path, e,))
+
returnValue(calendar)
raise HTTPError(ErrorResponse(responsecode.BAD_REQUEST))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100608/b6f427b5/attachment.html>
More information about the calendarserver-changes
mailing list