[CalendarServer-changes] [5324] CalendarServer/trunk/txcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Tue Mar 16 14:43:02 PDT 2010
Revision: 5324
http://trac.macosforge.org/projects/calendarserver/changeset/5324
Author: wsanchez at apple.com
Date: 2010-03-16 14:43:02 -0700 (Tue, 16 Mar 2010)
Log Message:
-----------
Start new resource classes.
Added Paths:
-----------
CalendarServer/trunk/txcaldav/resource/
CalendarServer/trunk/txcaldav/resource/__init__.py
CalendarServer/trunk/txcaldav/resource/calendar.py
Copied: CalendarServer/trunk/txcaldav/resource/__init__.py (from rev 5289, CalendarServer/trunk/txcaldav/__init__.py)
===================================================================
--- CalendarServer/trunk/txcaldav/resource/__init__.py (rev 0)
+++ CalendarServer/trunk/txcaldav/resource/__init__.py 2010-03-16 21:43:02 UTC (rev 5324)
@@ -0,0 +1,19 @@
+##
+# Copyright (c) 2010 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 resources.
+"""
Added: CalendarServer/trunk/txcaldav/resource/calendar.py
===================================================================
--- CalendarServer/trunk/txcaldav/resource/calendar.py (rev 0)
+++ CalendarServer/trunk/txcaldav/resource/calendar.py 2010-03-16 21:43:02 UTC (rev 5324)
@@ -0,0 +1,131 @@
+##
+# Copyright (c) 2010 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 resources.
+"""
+
+__all__ = [
+ "CalDAVResource",
+ "CalendarHomeResource",
+ "CalendarCollectionResource",
+ "CalendarObjectResource",
+ "ScheduleInboxResource",
+ "ScheduleOutboxResource",
+]
+
+
+import urllib
+
+from twext.python.log import LoggingMixIn
+from twext.web2.http_headers import MimeType
+from twext.web2.http import RedirectResponse, Response
+from twext.web2.stream import MemoryStream
+
+from twistedcaldav import config
+from twistedcaldav.extensions import DAVResource
+
+
+class CalDAVResource(DAVResource, LoggingMixIn):
+ """
+ CalDAV resource.
+ """
+ def davComplianceClasses(self):
+ return (
+ tuple(super(CalDAVResource, self).davComplianceClasses())
+ + config.CalDAVComplianceClasses
+ )
+
+
+class CalendarHomeResource(CalDAVResource):
+ """
+ Calendar home resource.
+
+ This resource is backed by an L{ICalendarHome} implementation.
+ """
+
+
+class CalendarCollectionResource(CalDAVResource):
+ """
+ Calendar collection resource.
+
+ This resource is backed by an L{ICalendar} implementation.
+ """
+ def render(self, request):
+ if config.EnableMonolithicCalendars:
+ #
+ # Send listing instead of iCalendar data to HTML agents
+ # This is mostly useful for debugging...
+ #
+ # FIXME: Add a self-link to the dirlist with a query string so
+ # users can still download the actual iCalendar data?
+ #
+ # FIXME: Are there better ways to detect this than hacking in
+ # user agents?
+ #
+ # FIXME: In the meantime, make this a configurable regex list?
+ #
+ agent = request.headers.getHeader("user-agent")
+ if agent is not None and (
+ agent.startswith("Mozilla/") and agent.find("Gecko") != -1
+ ):
+ renderAsHTML = True
+ else:
+ renderAsHTML = False
+ else:
+ renderAsHTML = True
+
+ if not renderAsHTML:
+ # Render a monolithic iCalendar file
+ if request.path[-1] != "/":
+ # Redirect to include trailing '/' in URI
+ return RedirectResponse(request.unparseURL(path=urllib.quote(urllib.unquote(request.path), safe=':/')+'/'))
+
+ def _defer(data):
+ response = Response()
+ response.stream = MemoryStream(str(data))
+ response.headers.setHeader("content-type", MimeType.fromString("text/calendar"))
+ return response
+
+ d = self.iCalendarRolledup(request)
+ d.addCallback(_defer)
+ return d
+
+ return super(CalDAVResource, self).render(request)
+
+
+class CalendarObjectResource(CalDAVResource):
+ """
+ Calendar object resource.
+
+ This resource is backed by an L{ICalendarObject} implementation.
+ """
+
+
+class ScheduleInboxResource(CalDAVResource):
+ """
+ Schedule inbox resource.
+
+ This resource is backed by an XXXXXXX implementation.
+ """
+
+
+class ScheduleOutboxResource(CalDAVResource):
+ """
+ Schedule outbox resource.
+
+ This resource is backed by an XXXXXXX implementation.
+ """
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100316/6c707358/attachment.html>
More information about the calendarserver-changes
mailing list