[CalendarServer-changes] [11092] CalendarServer/branches/users/cdaboo/store-scheduling

source_changes at macosforge.org source_changes at macosforge.org
Tue Apr 23 09:37:12 PDT 2013


Revision: 11092
          http://trac.calendarserver.org//changeset/11092
Author:   cdaboo at apple.com
Date:     2013-04-23 09:37:12 -0700 (Tue, 23 Apr 2013)
Log Message:
-----------
Checkpoint: various CDT fixes.

Modified Paths:
--------------
    CalendarServer/branches/users/cdaboo/store-scheduling/twistedcaldav/directory/aggregate.py
    CalendarServer/branches/users/cdaboo/store-scheduling/twistedcaldav/directory/directory.py
    CalendarServer/branches/users/cdaboo/store-scheduling/twistedcaldav/directory/principal.py
    CalendarServer/branches/users/cdaboo/store-scheduling/twistedcaldav/scheduling_store/caldav/resource.py
    CalendarServer/branches/users/cdaboo/store-scheduling/twistedcaldav/storebridge.py
    CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/file.py
    CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/freebusy.py
    CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/implicit.py
    CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/sql.py
    CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/test/common.py
    CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/test/test_implicit.py
    CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/util.py
    CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/icalendarstore.py

Modified: CalendarServer/branches/users/cdaboo/store-scheduling/twistedcaldav/directory/aggregate.py
===================================================================
--- CalendarServer/branches/users/cdaboo/store-scheduling/twistedcaldav/directory/aggregate.py	2013-04-23 14:26:50 UTC (rev 11091)
+++ CalendarServer/branches/users/cdaboo/store-scheduling/twistedcaldav/directory/aggregate.py	2013-04-23 16:37:12 UTC (rev 11092)
@@ -335,16 +335,16 @@
             service.setRealm(realmName)
 
 
-    def setPrincipalService(self, principalService):
+    def setPrincipalCollection(self, principalCollection):
         """
         Set the principal service that the directory relies on for doing proxy tests.
 
         @param principalService: the principal service.
         @type principalService: L{DirectoryProvisioningResource}
         """
-        self.principalService = principalService
+        self.principalCollection = principalCollection
         for service in self._recordTypes.values():
-            service.setPrincipalService(principalService)
+            service.setPrincipalCollection(principalCollection)
 
 
 

Modified: CalendarServer/branches/users/cdaboo/store-scheduling/twistedcaldav/directory/directory.py
===================================================================
--- CalendarServer/branches/users/cdaboo/store-scheduling/twistedcaldav/directory/directory.py	2013-04-23 14:26:50 UTC (rev 11091)
+++ CalendarServer/branches/users/cdaboo/store-scheduling/twistedcaldav/directory/directory.py	2013-04-23 16:37:12 UTC (rev 11092)
@@ -562,14 +562,14 @@
         raise NotImplementedError("Subclass must implement createRecords")
 
 
-    def setPrincipalService(self, principalService):
+    def setPrincipalCollection(self, principalCollection):
         """
         Set the principal service that the directory relies on for doing proxy tests.
 
         @param principalService: the principal service.
         @type principalService: L{DirectoryProvisioningResource}
         """
-        self.principalService = principalService
+        self.principalCollection = principalCollection
 
 
     def isProxyFor(self, test, other):
@@ -584,7 +584,7 @@
         @return: C{True} if test is a proxy of other.
         @rtype: C{bool}
         """
-        return self.principalService.proxyFor(self, other)
+        return self.principalCollection.isProxyFor(test, other)
 
 
 
@@ -1477,7 +1477,7 @@
         @return: C{True} if it is a proxy.
         @rtype: C{bool}
         """
-        return self.service.proxyFor(self, other)
+        return self.service.isProxyFor(self, other)
 
 
 

Modified: CalendarServer/branches/users/cdaboo/store-scheduling/twistedcaldav/directory/principal.py
===================================================================
--- CalendarServer/branches/users/cdaboo/store-scheduling/twistedcaldav/directory/principal.py	2013-04-23 14:26:50 UTC (rev 11091)
+++ CalendarServer/branches/users/cdaboo/store-scheduling/twistedcaldav/directory/principal.py	2013-04-23 16:37:12 UTC (rev 11092)
@@ -275,7 +275,7 @@
         DirectoryProvisioningResource.__init__(self, url, directory)
 
         # FIXME: Smells like a hack
-        self.directory.principalCollection = self
+        self.directory.setPrincipalCollection(self)
 
         #
         # Create children
@@ -391,7 +391,30 @@
         return (self,)
 
 
+    ##
+    # Proxy callback from directory service
+    ##
 
+    def isProxyFor(self, record1, record2):
+        """
+        Test whether the principal identified by directory record1 is a proxy for the principal identified by
+        record2.
+
+        @param record1: directory record for a user
+        @type record1: L{DirectoryRecord}
+        @param record2: directory record to test with
+        @type record2: L{DirectoryRercord}
+
+        @return: C{True} if record1 is a proxy for record2, otherwise C{False}
+        @rtype: C{bool}
+        """
+
+        principal1 = self.principalForUID(record1.uid)
+        principal2 = self.principalForUID(record2.uid)
+        return principal1.isProxyFor(principal2)
+
+
+
 class DirectoryPrincipalTypeProvisioningResource (DirectoryProvisioningResource):
     """
     Collection resource which provisions directory principals of a

Modified: CalendarServer/branches/users/cdaboo/store-scheduling/twistedcaldav/scheduling_store/caldav/resource.py
===================================================================
--- CalendarServer/branches/users/cdaboo/store-scheduling/twistedcaldav/scheduling_store/caldav/resource.py	2013-04-23 14:26:50 UTC (rev 11091)
+++ CalendarServer/branches/users/cdaboo/store-scheduling/twistedcaldav/scheduling_store/caldav/resource.py	2013-04-23 16:37:12 UTC (rev 11092)
@@ -426,7 +426,7 @@
                     originator = originatorPrincipal.canonicalCalendarUserAddress()
 
         if not originator:
-            self.log_err("%s request must have Originator" % (self.method,))
+            self.log_error("%s request must have Originator" % (self.method,))
             raise HTTPError(ErrorResponse(
                 responsecode.FORBIDDEN,
                 (caldav_namespace, "originator-specified"),
@@ -447,7 +447,7 @@
                 unique_set.add(attendee)
 
         if not attendees:
-            self.log_err("POST request must have at least one ATTENDEE")
+            self.log_error("POST request must have at least one ATTENDEE")
             raise HTTPError(ErrorResponse(
                 responsecode.FORBIDDEN,
                 (caldav_namespace, "recipient-specified"),

Modified: CalendarServer/branches/users/cdaboo/store-scheduling/twistedcaldav/storebridge.py
===================================================================
--- CalendarServer/branches/users/cdaboo/store-scheduling/twistedcaldav/storebridge.py	2013-04-23 14:26:50 UTC (rev 11091)
+++ CalendarServer/branches/users/cdaboo/store-scheduling/twistedcaldav/storebridge.py	2013-04-23 16:37:12 UTC (rev 11092)
@@ -62,7 +62,7 @@
     TooManyAttendeesError, InvalidCalendarAccessError, ValidOrganizerError, \
     UIDExistsError, InvalidUIDError, InvalidPerUserDataMerge, \
     AttendeeAllowedError, ResourceDeletedError, InvalidComponentForStoreError, \
-    InvalidResourceMove
+    InvalidResourceMove, UIDExistsElsewhereError
 from txdav.common.datastore.sql_tables import _BIND_MODE_READ, _BIND_MODE_WRITE, \
     _BIND_MODE_DIRECT
 from txdav.common.icommondatastore import NoSuchObjectResourceError, \
@@ -2558,6 +2558,7 @@
         InvalidCalendarAccessError: (calendarserver_namespace, "valid-access-restriction"),
         ValidOrganizerError: (calendarserver_namespace, "valid-organizer"),
         UIDExistsError: NoUIDConflict(),
+        UIDExistsElsewhereError: (caldav_namespace, "unique-scheduling-object-resource"),
         InvalidUIDError: NoUIDConflict(),
         InvalidPerUserDataMerge: (caldav_namespace, "valid-calendar-data"),
         AttendeeAllowedError: (caldav_namespace, "attendee-allowed"),

Modified: CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/file.py
===================================================================
--- CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/file.py	2013-04-23 14:26:50 UTC (rev 11091)
+++ CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/file.py	2013-04-23 16:37:12 UTC (rev 11092)
@@ -135,9 +135,9 @@
                 continue
             matched_type = "schedule" if objectResource.isScheduleObject else "calendar"
             if type == "schedule" or matched_type == "schedule":
-                returnValue(True)
+                returnValue(objectResource)
 
-        returnValue(False)
+        returnValue(None)
 
 
     @inlineCallbacks

Modified: CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/freebusy.py
===================================================================
--- CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/freebusy.py	2013-04-23 14:26:50 UTC (rev 11091)
+++ CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/freebusy.py	2013-04-23 16:37:12 UTC (rev 11092)
@@ -137,7 +137,7 @@
     organizer_uid = organizer_record.uid if organizer_record else ""
 
     # Free busy is per-user
-    useruid = calresource.ownerHome().uid()
+    useruid = calresource.viewerHome().uid()
     user_record = calresource.directoryService().recordWithUID(useruid)
 
     # Get the timezone property from the collection.

Modified: CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/implicit.py
===================================================================
--- CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/implicit.py	2013-04-23 14:26:50 UTC (rev 11091)
+++ CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/implicit.py	2013-04-23 16:37:12 UTC (rev 11092)
@@ -450,7 +450,7 @@
 
         # Check for matching resource somewhere else in the home
         foundElsewhere = (yield self.calendar_home.hasCalendarResourceUIDSomewhereElse(self.uid, check_resource, mode))
-        if foundElsewhere:
+        if foundElsewhere is not None:
             log.debug("Implicit - found component with same UID in a different collection: %s" % (check_resource,))
             raise HTTPError(ErrorResponse(
                 responsecode.FORBIDDEN,

Modified: CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/sql.py	2013-04-23 14:26:50 UTC (rev 11091)
+++ CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/sql.py	2013-04-23 16:37:12 UTC (rev 11092)
@@ -72,7 +72,8 @@
     InvalidUIDError, UIDExistsError, ResourceDeletedError, \
     AttendeeAllowedError, InvalidPerUserDataMerge, ComponentUpdateState, \
     ValidOrganizerError, ShareeAllowedError, ComponentRemoveState, \
-    InvalidComponentForStoreError, InvalidResourceMove, InvalidDefaultCalendar
+    InvalidComponentForStoreError, InvalidResourceMove, InvalidDefaultCalendar, \
+    UIDExistsElsewhereError
 from txdav.caldav.icalendarstore import QuotaExceeded
 from txdav.common.datastore.sql import CommonHome, CommonHomeChild, \
     CommonObjectResource, ECALENDARTYPE
@@ -518,9 +519,9 @@
                 continue
             matched_mode = ("schedule" if objectResource.isScheduleObject else "calendar")
             if mode == "schedule" or matched_mode == "schedule":
-                returnValue(True)
+                returnValue(objectResource)
 
-        returnValue(False)
+        returnValue(None)
 
 
     @inlineCallbacks
@@ -1950,8 +1951,11 @@
                 # New UID must be unique for the owner - no need to do this on an overwrite as we can assume
                 # the store is already consistent in this regard
                 elsewhere = (yield self.calendar().ownerHome().hasCalendarResourceUIDSomewhereElse(new_uid, self, "schedule"))
-                if elsewhere:
-                    raise UIDExistsError("UID already exists.")
+                if elsewhere is not None:
+                    if elsewhere.calendar().id() == self.calendar().id():
+                        raise UIDExistsError("UID already exists in same calendar.")
+                    else:
+                        raise UIDExistsElsewhereError("UID already exists in different calendar: %s." % (elsewhere.calendar().name(),))
 
 
     def setComponent(self, component, inserting=False, smart_merge=False):

Modified: CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/test/common.py
===================================================================
--- CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/test/common.py	2013-04-23 14:26:50 UTC (rev 11091)
+++ CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/test/common.py	2013-04-23 16:37:12 UTC (rev 11092)
@@ -1140,10 +1140,10 @@
         self.assertFalse(result)
 
         result = (yield home.hasCalendarResourceUIDSomewhereElse("uid1", object, "schedule"))
-        self.assertFalse(result)
+        self.assertFalse(result is not None)
 
         result = (yield home.hasCalendarResourceUIDSomewhereElse("uid2", object, "schedule"))
-        self.assertTrue(result)
+        self.assertTrue(result is not None)
 
         # FIXME:  do this without legacy calls
         '''
@@ -1158,7 +1158,7 @@
         result = (yield home.hasCalendarResourceUIDSomewhereElse(
             "uid2-5", object, "schedule"
         ))
-        self.assertFalse(result)
+        self.assertFalse(result is not None)
         '''
         yield None
 

Modified: CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/test/test_implicit.py
===================================================================
--- CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/test/test_implicit.py	2013-04-23 14:26:50 UTC (rev 11091)
+++ CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/test/test_implicit.py	2013-04-23 16:37:12 UTC (rev 11092)
@@ -27,7 +27,8 @@
     InvalidObjectResourceError
 from txdav.caldav.icalendarstore import InvalidComponentTypeError, \
     TooManyAttendeesError, InvalidCalendarAccessError, InvalidUIDError, \
-    UIDExistsError, ComponentUpdateState, InvalidComponentForStoreError
+    UIDExistsError, ComponentUpdateState, InvalidComponentForStoreError, \
+    UIDExistsElsewhereError
 from txdav.common.datastore.sql_tables import _BIND_MODE_WRITE
 from txdav.caldav.datastore.test.util import buildCalendarStore
 
@@ -473,7 +474,7 @@
         home_collection = (yield self.homeUnderTest(name="user01"))
         calendar_collection_2 = (yield home_collection.createCalendarWithName("calendar_2"))
         calendar = Component.fromString(data2)
-        yield self.failUnlessFailure(calendar_collection_2.createCalendarObjectWithName("test2.ics", calendar), UIDExistsError)
+        yield self.failUnlessFailure(calendar_collection_2.createCalendarObjectWithName("test2.ics", calendar), UIDExistsElsewhereError)
         yield self.commit()
 
 

Modified: CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/util.py
===================================================================
--- CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/util.py	2013-04-23 14:26:50 UTC (rev 11091)
+++ CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/util.py	2013-04-23 16:37:12 UTC (rev 11092)
@@ -219,7 +219,7 @@
             mightConflict = yield outHome.hasCalendarResourceUIDSomewhereElse(
                 calendarObject.uid(), None, "schedule"
             )
-            if mightConflict:
+            if mightConflict is not None:
                 log.warn(
                     "Not migrating object %s/%s/%s due to potential conflict" %
                     (outHome.uid(), outCalendar.name(), calendarObject.name())

Modified: CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/icalendarstore.py
===================================================================
--- CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/icalendarstore.py	2013-04-23 14:26:50 UTC (rev 11091)
+++ CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/icalendarstore.py	2013-04-23 16:37:12 UTC (rev 11092)
@@ -153,11 +153,18 @@
 
 class UIDExistsError(CommonStoreError):
     """
-    The UID of the component in a store operation exists in another calendar belonging to the owner.
+    The UID of the component in a store operation exists in the same calendar belonging to the owner.
     """
 
 
 
+class UIDExistsElsewhereError(CommonStoreError):
+    """
+    The UID of the component in a store operation exists in different calendar belonging to the owner.
+    """
+
+
+
 class ResourceDeletedError(CommonStoreError):
     """
     The resource was determined to be redundant and was deleted by the server.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130423/bb1eab7c/attachment-0001.html>


More information about the calendarserver-changes mailing list