[CalendarServer-changes] [5005] CalendarServer/branches/users/glyph/contacts-server-merge/ twistedcaldav/method

source_changes at macosforge.org source_changes at macosforge.org
Mon Feb 1 16:59:14 PST 2010


Revision: 5005
          http://trac.macosforge.org/projects/calendarserver/changeset/5005
Author:   glyph at apple.com
Date:     2010-02-01 16:59:14 -0800 (Mon, 01 Feb 2010)
Log Message:
-----------
minimalist delegation of work to version of COPY/MOVE methods present in !ContactsServer when no special calendar work is warranted.

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/contacts-server-merge/twistedcaldav/method/copymove.py
    CalendarServer/branches/users/glyph/contacts-server-merge/twistedcaldav/method/copymove_contact.py

Removed Paths:
-------------
    CalendarServer/branches/users/glyph/contacts-server-merge/twistedcaldav/method/delete_contact.py

Modified: CalendarServer/branches/users/glyph/contacts-server-merge/twistedcaldav/method/copymove.py
===================================================================
--- CalendarServer/branches/users/glyph/contacts-server-merge/twistedcaldav/method/copymove.py	2010-02-02 00:25:46 UTC (rev 5004)
+++ CalendarServer/branches/users/glyph/contacts-server-merge/twistedcaldav/method/copymove.py	2010-02-02 00:59:14 UTC (rev 5005)
@@ -32,10 +32,20 @@
 
 from twistedcaldav.caldavxml import caldav_namespace
 from twistedcaldav.method.put_common import StoreCalendarObjectResource
+from twistedcaldav.method.copymove_contact import (
+    maybeCOPYContact, maybeMOVEContact, KEEP_GOING
+)
+
 from twistedcaldav.resource import isCalendarCollectionResource,\
     isPseudoCalendarCollectionResource
 from twistedcaldav.log import Logger
 
+CalDAVFile = None               # Pacify PyFlakes; this *should* be fixed, but
+                                # it's not actually an undefined name, as the
+                                # bottom of twistedcaldav.static fixes it up
+                                # for us before any functions in this module
+                                # are invoked.
+
 log = Logger()
 
 @inlineCallbacks
@@ -53,8 +63,10 @@
 
     result, sourcecal, sourceparent, destination_uri, destination, destinationcal, destinationparent = (yield checkForCalendarAction(self, request))
     if not result or not destinationcal:
-        # Do default WebDAV action
-        result = (yield super(CalDAVFile, self).http_COPY(request))
+        # Check with CardDAV first (XXX might want to check EnableCardDAV switch?)
+        result = yield maybeCOPYContact(self, request)
+        if result is KEEP_GOING:
+            result = yield super(CalDAVFile, self).http_COPY(request)
         returnValue(result)
 
     #
@@ -121,6 +133,11 @@
         is_calendar_collection = isPseudoCalendarCollectionResource(self)
         defaultCalendar = (yield self.isDefaultCalendar(request)) if is_calendar_collection else False
 
+        if not is_calendar_collection:
+            result = yield maybeMOVEContact(self, request)
+            if result is not KEEP_GOING:
+                returnValue(result)
+
         # Do default WebDAV action
         result = (yield super(CalDAVFile, self).http_MOVE(request))
         

Modified: CalendarServer/branches/users/glyph/contacts-server-merge/twistedcaldav/method/copymove_contact.py
===================================================================
--- CalendarServer/branches/users/glyph/contacts-server-merge/twistedcaldav/method/copymove_contact.py	2010-02-02 00:25:46 UTC (rev 5004)
+++ CalendarServer/branches/users/glyph/contacts-server-merge/twistedcaldav/method/copymove_contact.py	2010-02-02 00:59:14 UTC (rev 5005)
@@ -18,7 +18,7 @@
 CalDAV COPY and MOVE methods.
 """
 
-__all__ = ["http_COPY", "http_MOVE"]
+__all__ = ["maybeCOPYContact", "maybeMOVEContact"]
 
 from urlparse import urlsplit
 
@@ -37,24 +37,25 @@
 
 log = Logger()
 
+KEEP_GOING = object()
+
 @inlineCallbacks
-def http_COPY(self, request):
+def maybeCOPYContact(self, request):
     """
     Special handling of COPY request if parents are addressbook collections.
     When copying we do not have to worry about the source resource as it
     is not being changed in any way. We do need to do an index update for
     the destination if its an addressbook collection.
     """
-
     # Copy of addressbook collections isn't allowed.
     if isAddressBookCollectionResource(self):
         returnValue(responsecode.FORBIDDEN)
 
     result, sourceadbk, sourceparent, destination_uri, destination, destinationadbk, destinationparent = (yield checkForAddressBookAction(self, request))
     if not result or not destinationadbk:
-        # Do default WebDAV action
-        result = (yield super(CalDAVFile, self).http_COPY(request))
-        returnValue(result)
+        # Give up, do default action.
+        
+        returnValue(KEEP_GOING)
 
     #
     # Check authentication and access controls
@@ -108,7 +109,7 @@
     returnValue(result)
 
 @inlineCallbacks
-def http_MOVE(self, request):
+def maybeMOVEContact(self, request):
     """
     Special handling of MOVE request if parent is an addressbook collection.
     When moving we may need to remove the index entry for the source resource
@@ -123,8 +124,7 @@
             yield self.updateCTag()
             
         # Do default WebDAV action
-        result = (yield super(CalDAVFile, self).http_MOVE(request))
-        returnValue(result)
+        returnValue(KEEP_GOING)
         
     #
     # Check authentication and access controls

Deleted: CalendarServer/branches/users/glyph/contacts-server-merge/twistedcaldav/method/delete_contact.py
===================================================================
--- CalendarServer/branches/users/glyph/contacts-server-merge/twistedcaldav/method/delete_contact.py	2010-02-02 00:25:46 UTC (rev 5004)
+++ CalendarServer/branches/users/glyph/contacts-server-merge/twistedcaldav/method/delete_contact.py	2010-02-02 00:59:14 UTC (rev 5005)
@@ -1,59 +0,0 @@
-##
-# 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 DELETE method.
-"""
-
-__all__ = ["http_DELETE"]
-
-from twisted.internet.defer import inlineCallbacks, returnValue
-from twisted.web2 import responsecode
-from twisted.web2.dav import davxml
-from twisted.web2.dav.util import parentForURL
-from twisted.web2.http import HTTPError
-
-from twistedcaldav.method.delete_common import DeleteResource
-from twistedcaldav.log import Logger
-
-log = Logger()
-
- at inlineCallbacks
-def http_DELETE(self, request):
-    #
-    # Override base DELETE request handling to ensure that the calendar
-    # index file has the entry for the deleted calendar component removed.
-    #
-
-    if not self.fp.exists():
-        log.err("File not found: %s" % (self.fp.path,))
-        raise HTTPError(responsecode.NOT_FOUND)
-
-    depth = request.headers.getHeader("depth", "infinity")
-
-    #
-    # Check authentication and access controls
-    #
-    parentURL = parentForURL(request.uri)
-    parent = (yield request.locateResource(parentURL))
-
-    yield parent.authorize(request, (davxml.Unbind(),))
-
-    # Do smart delete taking into account the need to do implicit CANCELs etc
-    deleter = DeleteResource(request, self, request.uri, parent, depth)
-    response = (yield deleter.run())
-
-    returnValue(response)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100201/96783c05/attachment-0001.html>


More information about the calendarserver-changes mailing list