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

source_changes at macosforge.org source_changes at macosforge.org
Sun Apr 21 07:53:53 PDT 2013


Revision: 11081
          http://trac.calendarserver.org//changeset/11081
Author:   cdaboo at apple.com
Date:     2013-04-21 07:53:53 -0700 (Sun, 21 Apr 2013)
Log Message:
-----------
Checkpoint: various implicit fixes. Next up freebusy.

Modified Paths:
--------------
    CalendarServer/branches/users/cdaboo/store-scheduling/twistedcaldav/directory/directory.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/scheduling/implicit.py
    CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/sql.py

Modified: CalendarServer/branches/users/cdaboo/store-scheduling/twistedcaldav/directory/directory.py
===================================================================
--- CalendarServer/branches/users/cdaboo/store-scheduling/twistedcaldav/directory/directory.py	2013-04-20 21:17:37 UTC (rev 11080)
+++ CalendarServer/branches/users/cdaboo/store-scheduling/twistedcaldav/directory/directory.py	2013-04-21 14:53:53 UTC (rev 11081)
@@ -14,8 +14,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 ##
-from txdav.caldav.icalendardirectoryservice import ICalendarStoreDirectoryService, \
-    ICalendarStoreDirectoryRecord
 
 
 """
@@ -31,40 +29,44 @@
     "GroupMembershipCacheUpdater",
 ]
 
-import cPickle as pickle
-import datetime
-import grp
-import itertools
-import os
-import pwd
-import sys
-import types
+from plistlib import readPlistFromString
 
+from twext.enterprise.dal.record import fromTable
+from twext.enterprise.dal.syntax import Delete
+from twext.enterprise.queue import WorkItem
+from twext.python.log import Logger, LoggingMixIn
+from twext.web2.dav.auth import IPrincipalCredentials
+from twext.web2.dav.util import joinURL
 
-from zope.interface import implements
-
-from twisted.cred.error import UnauthorizedLogin
 from twisted.cred.checkers import ICredentialsChecker
-from twext.web2.dav.auth import IPrincipalCredentials
+from twisted.cred.error import UnauthorizedLogin
 from twisted.internet.defer import succeed, inlineCallbacks, returnValue
+from twisted.python.filepath import FilePath
 
-from twext.python.log import Logger, LoggingMixIn
-
 from twistedcaldav.config import config
-
 from twistedcaldav.directory.idirectory import IDirectoryService, IDirectoryRecord
 from twistedcaldav.directory.util import uuidFromName, normalizeUUID
+from twistedcaldav.memcacher import Memcacher
 from twistedcaldav.scheduling.cuaddress import normalizeCUAddr
 from twistedcaldav.scheduling.ischedule.localservers import Servers
-from twistedcaldav.memcacher import Memcacher
-from twisted.python.filepath import FilePath
-from xml.parsers.expat import ExpatError
-from plistlib import readPlistFromString
-from twext.enterprise.dal.record import fromTable
-from twext.enterprise.queue import WorkItem
+
+from txdav.caldav.icalendardirectoryservice import ICalendarStoreDirectoryService, \
+    ICalendarStoreDirectoryRecord
 from txdav.common.datastore.sql_tables import schema
-from twext.enterprise.dal.syntax import Delete
 
+from xml.parsers.expat import ExpatError
+
+from zope.interface import implements
+
+import cPickle as pickle
+import datetime
+import grp
+import itertools
+import os
+import pwd
+import sys
+import types
+
 log = Logger()
 
 
@@ -114,14 +116,6 @@
         self.realmName = realmName
 
 
-    def getPrincipalPath(self):
-        return getattr(self, "principalPath", None)
-
-
-    def setPrincipalPath(self, principalPath):
-        self.principalPath = principalPath
-
-
     def available(self):
         """
         By default, the directory is available.  This may return a boolean or a
@@ -233,6 +227,14 @@
                     break
             else:
                 return None
+        elif address.startswith("/principals/"):
+            parts = address.split("/")
+            if len(parts) == 3:
+                if parts[1] == "__uids__":
+                    guid = parts[2]
+                    record = self.recordWithGUID(guid)
+                else:
+                    record = self.recordWithShortName(parts[1], parts[2])
 
         return record if record and record.enabledForCalendaring else None
 
@@ -1086,14 +1088,11 @@
             ["mailto:%s" % (emailAddress,)
              for emailAddress in self.emailAddresses]
         )
-        path = self.service.getPrincipalPath()
         if self.guid:
             cuas.add("urn:uuid:%s" % (self.guid,))
-            if path:
-                cuas.add("/%s/__uids__/%s/" % (path, self.guid,))
-        if path:
-            for shortName in self.shortNames:
-                cuas.add("/%s/%s/%s/" % (path, self.recordType, shortName,))
+            cuas.add(joinURL("/principals", "__uids__", self.guid) + "/")
+        for shortName in self.shortNames:
+            cuas.add(joinURL("/principals", self.recordType, shortName,) + "/")
 
         return frozenset(cuas)
 

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-20 21:17:37 UTC (rev 11080)
+++ CalendarServer/branches/users/cdaboo/store-scheduling/twistedcaldav/scheduling_store/caldav/resource.py	2013-04-21 14:53:53 UTC (rev 11081)
@@ -282,6 +282,13 @@
                 "Invalid HRef in property",
             ))
 
+        if cal is None or not cal.exists():
+            raise HTTPError(ErrorResponse(
+                responsecode.BAD_REQUEST,
+                error_element,
+                "HRef is not a valid calendar",
+            ))
+
         try:
             # Now set it on the new store object
             yield self.parent._newStoreHome.setDefaultCalendar(cal._newStoreObject, tasks)

Modified: CalendarServer/branches/users/cdaboo/store-scheduling/twistedcaldav/storebridge.py
===================================================================
--- CalendarServer/branches/users/cdaboo/store-scheduling/twistedcaldav/storebridge.py	2013-04-20 21:17:37 UTC (rev 11080)
+++ CalendarServer/branches/users/cdaboo/store-scheduling/twistedcaldav/storebridge.py	2013-04-21 14:53:53 UTC (rev 11081)
@@ -2636,6 +2636,12 @@
                 # This is OK - it just means the server deleted the resource during the PUT. We make it look
                 # like the PUT succeeded.
                 response = responsecode.CREATED if self.exists() else responsecode.NO_CONTENT
+
+                # Re-initialize to get stuff setup again now we have no object
+                self._initializeWithObject(None, self._newStoreParent)
+
+                returnValue(response)
+
             response = IResponse(response)
 
             if self._newStoreObject.isScheduleObject:
@@ -2690,6 +2696,25 @@
         return self.storeRemove(request)
 
 
+    @inlineCallbacks
+    def http_MOVE(self, request):
+        """
+        Need If-Schedule-Tag-Match behavior
+        """
+
+        # Do some pre-flight checks - must exist, must be move to another
+        # CommonHomeChild in the same Home, destination resource must not exist
+        if not self.exists():
+            log.debug("Resource not found: %s" % (self,))
+            raise HTTPError(NOT_FOUND)
+
+        # Do schedule tag check
+        self.validIfScheduleMatch(request)
+
+        result = (yield super(CalendarObjectResource, self).http_MOVE(request))
+        returnValue(result)
+
+
     @requiresPermissions(davxml.WriteContent())
     @inlineCallbacks
     def POST_handler_attachment(self, request, action):

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-20 21:17:37 UTC (rev 11080)
+++ CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/scheduling/implicit.py	2013-04-21 14:53:53 UTC (rev 11081)
@@ -882,7 +882,7 @@
             if attendee.parameterValue("SCHEDULE-AGENT", "SERVER").upper() == "CLIENT":
                 cuaddr = attendee.value()
                 if cuaddr not in coerced:
-                    attendeePrincipal = self.resource.directoryService().recordWithCalendarUserAddress(cuaddr)
+                    attendeePrincipal = self.calendar_home.directoryService().recordWithCalendarUserAddress(cuaddr)
                     attendeeAddress = (yield addressmapping.mapper.getCalendarUser(cuaddr, attendeePrincipal))
                     local_attendee = type(attendeeAddress) in (LocalCalendarUser, PartitionedCalendarUser, OtherServerCalendarUser,)
                     coerced[cuaddr] = local_attendee

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-20 21:17:37 UTC (rev 11080)
+++ CalendarServer/branches/users/cdaboo/store-scheduling/txdav/caldav/datastore/sql.py	2013-04-21 14:53:53 UTC (rev 11081)
@@ -1891,7 +1891,7 @@
             # Check what kind of processing is going on
             change_scheduletag = not (
                 (internal_state == ComponentUpdateState.ORGANIZER_ITIP_UPDATE) or
-                (internal_state == ComponentUpdateState.ATTENDEE_ITIP_UPDATE) and not hasattr(self._txn, "doing_attendee_refresh")
+                (internal_state == ComponentUpdateState.ATTENDEE_ITIP_UPDATE) and hasattr(self._txn, "doing_attendee_refresh")
             )
 
             if change_scheduletag or not self.scheduleTag:
@@ -1996,7 +1996,7 @@
 
                     # Now forcibly delete the event
                     if not inserting:
-                        yield self.storeRemove()
+                        yield self._removeInternal(internal_state=ComponentRemoveState.INTERNAL)
                         raise ResourceDeletedError("Resource modified but immediately deleted by the server.")
                     else:
                         raise AttendeeAllowedError("Attendee cannot create event for Organizer: %s" % (implicit_result,))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130421/dd678592/attachment-0001.html>


More information about the calendarserver-changes mailing list