[CalendarServer-changes] [7317] CalendarServer/branches/users/cdaboo/pods

source_changes at macosforge.org source_changes at macosforge.org
Thu Apr 14 13:16:33 PDT 2011


Revision: 7317
          http://trac.macosforge.org/projects/calendarserver/changeset/7317
Author:   cdaboo at apple.com
Date:     2011-04-14 13:16:32 -0700 (Thu, 14 Apr 2011)
Log Message:
-----------
Make server-to-server work.

Modified Paths:
--------------
    CalendarServer/branches/users/cdaboo/pods/calendarserver/tap/util.py
    CalendarServer/branches/users/cdaboo/pods/twistedcaldav/directory/principal.py
    CalendarServer/branches/users/cdaboo/pods/twistedcaldav/schedule.py
    CalendarServer/branches/users/cdaboo/pods/twistedcaldav/scheduling/implicit.py
    CalendarServer/branches/users/cdaboo/pods/twistedcaldav/scheduling/ischedule.py
    CalendarServer/branches/users/cdaboo/pods/twistedcaldav/scheduling/scheduler.py
    CalendarServer/branches/users/cdaboo/pods/twistedcaldav/servers.py
    CalendarServer/branches/users/cdaboo/pods/twistedcaldav/stdconfig.py

Modified: CalendarServer/branches/users/cdaboo/pods/calendarserver/tap/util.py
===================================================================
--- CalendarServer/branches/users/cdaboo/pods/calendarserver/tap/util.py	2011-04-14 00:08:52 UTC (rev 7316)
+++ CalendarServer/branches/users/cdaboo/pods/calendarserver/tap/util.py	2011-04-14 20:16:32 UTC (rev 7317)
@@ -519,6 +519,7 @@
 
         ischedule = iScheduleResourceClass(
             root,
+            newStore,
         )
         root.putChild("ischedule", ischedule)
 

Modified: CalendarServer/branches/users/cdaboo/pods/twistedcaldav/directory/principal.py
===================================================================
--- CalendarServer/branches/users/cdaboo/pods/twistedcaldav/directory/principal.py	2011-04-14 00:08:52 UTC (rev 7316)
+++ CalendarServer/branches/users/cdaboo/pods/twistedcaldav/directory/principal.py	2011-04-14 20:16:32 UTC (rev 7317)
@@ -951,6 +951,11 @@
                 uidsResourceName,
                 self.record.uid
             ) + "/"
+            
+            # Prefix with other server if needed
+            if not self.thisServer():
+                self.calendarHomeURL = joinURL(self.serverURI(), self.calendarHomeURL)
+
         url = self.calendarHomeURL
         if url is None:
             return None
@@ -976,6 +981,11 @@
                 uidsResourceName,
                 self.record.uid
             ) + "/"
+            
+            # Prefix with other server if needed
+            if not self.thisServer():
+                self.addressBookHomeURL = joinURL(self.serverURI(), self.addressBookHomeURL)
+
         url = self.addressBookHomeURL
         if url is None:
             return None

Modified: CalendarServer/branches/users/cdaboo/pods/twistedcaldav/schedule.py
===================================================================
--- CalendarServer/branches/users/cdaboo/pods/twistedcaldav/schedule.py	2011-04-14 00:08:52 UTC (rev 7316)
+++ CalendarServer/branches/users/cdaboo/pods/twistedcaldav/schedule.py	2011-04-14 20:16:32 UTC (rev 7317)
@@ -379,7 +379,7 @@
     Extends L{DAVResource} to provide iSchedule inbox functionality.
     """
 
-    def __init__(self, parent):
+    def __init__(self, parent, store):
         """
         @param parent: the parent resource of this one.
         """
@@ -388,6 +388,7 @@
         DAVResource.__init__(self, principalCollections=parent.principalCollections())
 
         self.parent = parent
+        self._newStore = store
 
     def deadProperties(self):
         if not hasattr(self, "_dead_properties"):
@@ -412,6 +413,13 @@
     def isPseudoCalendarCollection(self):
         return False
 
+    def principalForCalendarUserAddress(self, address):
+        for principalCollection in self.principalCollections():
+            principal = principalCollection.principalForCalendarUserAddress(address)
+            if principal is not None:
+                return principal
+        return None
+
     def render(self, request):
         output = """<html>
 <head>
@@ -438,8 +446,18 @@
         # This is a server-to-server scheduling operation.
         scheduler = IScheduleScheduler(request, self)
 
+        # Need a transaction to work with
+        txn = self._newStore.newTransaction("new transaction for Server To Server Inbox Resource")
+        request._newStoreTransaction = txn
+         
         # Do the POST processing treating this as a non-local schedule
-        result = (yield scheduler.doSchedulingViaPOST(use_request_headers=True))
+        try:
+            result = (yield scheduler.doSchedulingViaPOST(use_request_headers=True))
+        except Exception, e:
+            yield txn.abort()
+            raise e
+        else:
+            yield txn.commit()
         returnValue(result.response())
 
     ##

Modified: CalendarServer/branches/users/cdaboo/pods/twistedcaldav/scheduling/implicit.py
===================================================================
--- CalendarServer/branches/users/cdaboo/pods/twistedcaldav/scheduling/implicit.py	2011-04-14 00:08:52 UTC (rev 7316)
+++ CalendarServer/branches/users/cdaboo/pods/twistedcaldav/scheduling/implicit.py	2011-04-14 20:16:32 UTC (rev 7317)
@@ -915,7 +915,7 @@
     def checkOrganizerScheduleAgent(self):
 
         is_server = self.calendar.getOrganizerScheduleAgent()
-        local_organizer = isinstance(self.organizerAddress, LocalCalendarUser)
+        local_organizer = type(self.organizerAddress) in (LocalCalendarUser, PartitionedCalendarUser, OtherServerCalendarUser,)
 
         if config.Scheduling.iMIP.Enabled and self.organizerAddress.cuaddr.lower().startswith("mailto:"):
             return True

Modified: CalendarServer/branches/users/cdaboo/pods/twistedcaldav/scheduling/ischedule.py
===================================================================
--- CalendarServer/branches/users/cdaboo/pods/twistedcaldav/scheduling/ischedule.py	2011-04-14 00:08:52 UTC (rev 7316)
+++ CalendarServer/branches/users/cdaboo/pods/twistedcaldav/scheduling/ischedule.py	2011-04-14 20:16:32 UTC (rev 7317)
@@ -179,10 +179,10 @@
                 proto = (yield ClientCreator(reactor, HTTPClientProtocol).connectTCP(self.server.host, self.server.port))
             
             request = ClientRequest("POST", self.server.path, self.headers, self.data)
-            yield log.logRequest("debug", "Sending server-to-server POST request:", request)
+            yield self.logRequest("debug", "Sending server-to-server POST request:", request)
             response = (yield proto.submitRequest(request))
     
-            yield log.logResponse("debug", "Received server-to-server POST response:", response)
+            yield self.logResponse("debug", "Received server-to-server POST response:", response)
             xml = (yield davXMLFromStream(response.stream))
     
             self._parseResponse(xml)
@@ -205,7 +205,7 @@
 
         assert level in logLevels
 
-        if self.willLogAtLevel(level):
+        if log.willLogAtLevel(level):
             iostr = StringIO()
             iostr.write("%s\n" % (message,))
             if hasattr(request, "clientproto"):
@@ -231,7 +231,7 @@
                 request.stream = MemoryStream(data if data is not None else "")
                 request.stream.doStartReading = None
             
-                self.emit(level, iostr.getvalue(), **kwargs)
+                log.emit(level, iostr.getvalue(), **kwargs)
 
             d = allDataFromStream(request.stream)
             d.addCallback(_gotData)
@@ -246,7 +246,7 @@
         """
         assert level in logLevels
 
-        if self.willLogAtLevel(level):
+        if log.willLogAtLevel(level):
             iostr = StringIO()
             iostr.write("%s\n" % (message,))
             code_message = responsecode.RESPONSES.get(response.code, "Unknown Status")
@@ -269,7 +269,7 @@
                 response.stream = MemoryStream(data if data is not None else "")
                 response.stream.doStartReading = None
             
-                self.emit(level, iostr.getvalue(), **kwargs)
+                log.emit(level, iostr.getvalue(), **kwargs)
                 
             d = allDataFromStream(response.stream)
             d.addCallback(_gotData)

Modified: CalendarServer/branches/users/cdaboo/pods/twistedcaldav/scheduling/scheduler.py
===================================================================
--- CalendarServer/branches/users/cdaboo/pods/twistedcaldav/scheduling/scheduler.py	2011-04-14 00:08:52 UTC (rev 7316)
+++ CalendarServer/branches/users/cdaboo/pods/twistedcaldav/scheduling/scheduler.py	2011-04-14 20:16:32 UTC (rev 7317)
@@ -907,8 +907,11 @@
         Check the validity of the partitioned host.
         """
 
-        # Extract expected host/port
-        expected_uri = principal.partitionURI() if principal.thisServer() else principal.serverURI()
+        # Extract expected host/port. This will be the partitionURI, or if no partitions,
+        # the serverURI
+        expected_uri = principal.partitionURI()
+        if expected_uri is None:
+            expected_uri = principal.serverURI()
         expected_uri = urlparse.urlparse(expected_uri)
     
         # Get the request IP and map to hostname.

Modified: CalendarServer/branches/users/cdaboo/pods/twistedcaldav/servers.py
===================================================================
--- CalendarServer/branches/users/cdaboo/pods/twistedcaldav/servers.py	2011-04-14 00:08:52 UTC (rev 7316)
+++ CalendarServer/branches/users/cdaboo/pods/twistedcaldav/servers.py	2011-04-14 20:16:32 UTC (rev 7317)
@@ -58,11 +58,9 @@
             if xmlFile:
                 self._xmlFile = xmlFile
             else:
-                self._xmlFile = FilePath(
-                    fullServerPath(
-                        config.ConfigRoot,
-                        config.Servers.ConfigFile
-                    )
+                self._xmlFile = fullServerPath(
+                    config.ConfigRoot,
+                    config.Servers.ConfigFile
                 )
         self._servers = ServersParser.parse(self._xmlFile)
         for server in self._servers.values():
@@ -70,7 +68,7 @@
                 self._thisServer = server
                 break
         else:
-            raise ValueError("No server in self._xmlFile matches this server.")
+            raise ValueError("No server in %s matches this server." % (self._xmlFile,))
     
     def clear(self):
         self._servers = {}
@@ -82,7 +80,7 @@
         
     def getServerURIById(self, id):
         try:
-            return self._servers.get[id].uri
+            return self._servers[id].uri
         except KeyError:
             return None
     

Modified: CalendarServer/branches/users/cdaboo/pods/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/branches/users/cdaboo/pods/twistedcaldav/stdconfig.py	2011-04-14 00:08:52 UTC (rev 7316)
+++ CalendarServer/branches/users/cdaboo/pods/twistedcaldav/stdconfig.py	2011-04-14 20:16:32 UTC (rev 7317)
@@ -759,11 +759,7 @@
         if "Includes" in configDict:
             configRoot = os.path.join(configDict.ServerRoot, configDict.ConfigRoot)
             for include in configDict.Includes:
-                path = fullServerPath(configRoot, include)
-                if '$' in path:
-                    path = path.replace('$', getfqdn())
-                if '#' in path:
-                    path = path.replace('#', gethostbyname(getfqdn()))
+                path = _expandPath(fullServerPath(configRoot, include))
                 additionalDict = self._parseConfigFromFile(path)
                 if additionalDict:
                     log.info("Adding configuration from file: '%s'" % (path,))
@@ -783,6 +779,13 @@
             configDict = _cleanup(configDict, self._defaults)
         return configDict
 
+def _expandPath(path):
+    if '$' in path:
+        return path.replace('$', getfqdn())
+    elif '#' in path:
+        return path.replace('#', gethostbyname(getfqdn()))
+    else:
+        return path
 
 RELATIVE_PATHS = [
     ("ServerRoot", "DataRoot"),
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110414/2941fa17/attachment-0001.html>


More information about the calendarserver-changes mailing list